Skip to content

Commit a755abf

Browse files
authored
Merge pull request #54 from softprops/github-actions
try github actions
2 parents d89d6ac + e054969 commit a755abf

File tree

4 files changed

+62
-17
lines changed

4 files changed

+62
-17
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Main
2+
3+
on: push
4+
5+
jobs:
6+
unit-test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v1
11+
- name: Install
12+
run: npm ci
13+
- name: Test
14+
run: npm test
15+
integration-test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v1
20+
- name: Test
21+
run: tests/test.sh
22+
publish:
23+
needs: [unit-test, integration-test]
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v1
28+
- name: Publish
29+
if: startsWith(github.ref, 'refs/tags/')
30+
run: |
31+
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
32+
npm publish
33+
env:
34+
CI: true
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

index.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const BASE_RUNTIME = "provided";
1414
const NO_OUTPUT_CAPTURE = { stdio: ["ignore", process.stdout, process.stderr] };
1515

1616
function includeInvokeHook(serverlessVersion) {
17-
let [major, minor] = serverlessVersion.split('.');
17+
let [major, minor] = serverlessVersion.split(".");
1818
let majorVersion = parseInt(major);
1919
let minorVersion = parseInt(minor);
2020
return majorVersion === 1 && minorVersion >= 38 && minorVersion < 40;
@@ -28,10 +28,10 @@ class RustPlugin {
2828
this.servicePath = this.serverless.config.servicePath || "";
2929
this.hooks = {
3030
"before:package:createDeploymentArtifacts": this.build.bind(this),
31-
"before:deploy:function:packageFunction": this.build.bind(this),
31+
"before:deploy:function:packageFunction": this.build.bind(this)
3232
};
3333
if (includeInvokeHook(serverless.version)) {
34-
this.hooks['before:invoke:local:invoke'] = this.build.bind(this);
34+
this.hooks["before:invoke:local:invoke"] = this.build.bind(this);
3535
}
3636
this.custom = Object.assign(
3737
{
@@ -51,17 +51,21 @@ class RustPlugin {
5151
}
5252

5353
runDocker(funcArgs, cargoPackage, binary) {
54-
const cargoHome = process.env.CARGO_HOME || (path.join(homedir(), ".cargo"));
54+
const cargoHome = process.env.CARGO_HOME || path.join(homedir(), ".cargo");
5555
const cargoRegistry = path.join(cargoHome, "registry");
5656
const cargoDownloads = path.join(cargoHome, "git");
5757
const defaultArgs = [
58-
'run',
59-
'--rm',
60-
'-t',
61-
'-e', `BIN=${binary}`,
62-
`-v`, `${this.servicePath}:/code`,
63-
`-v`, `${cargoRegistry}:/root/.cargo/registry`,
64-
`-v`, `${cargoDownloads}:/root/.cargo/git`,
58+
"run",
59+
"--rm",
60+
"-t",
61+
"-e",
62+
`BIN=${binary}`,
63+
`-v`,
64+
`${this.servicePath}:/code`,
65+
`-v`,
66+
`${cargoRegistry}:/root/.cargo/registry`,
67+
`-v`,
68+
`${cargoDownloads}:/root/.cargo/git`
6569
];
6670
const customArgs = [];
6771
let cargoFlags = (funcArgs || {}).cargoFlags || this.custom.cargoFlags;
@@ -114,9 +118,7 @@ class RustPlugin {
114118
const res = this.runDocker(func.rust, cargoPackage, binary);
115119
if (res.error || res.status > 0) {
116120
this.serverless.cli.log(
117-
`Dockerized Rust build encountered an error: ${res.error} ${
118-
res.status
119-
}.`
121+
`Dockerized Rust build encountered an error: ${res.error} ${res.status}.`
120122
);
121123
throw new Error(res.error);
122124
}

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Serverless framework plugin for Rustlang applications",
55
"main": "index.js",
66
"scripts": {
7-
"test": "npx eslint ."
7+
"test": "eslint *.js && prettier --check '*.js'",
8+
"fmt": "prettier --write '*.js'"
89
},
910
"repository": {
1011
"type": "git",
@@ -28,7 +29,8 @@
2829
"serverless": "^1.53.0"
2930
},
3031
"devDependencies": {
31-
"eslint": "^6.5.0"
32+
"eslint": "^6.5.0",
33+
"prettier": "^1.18.2"
3234
},
3335
"files": [
3436
"index.js",

0 commit comments

Comments
 (0)