-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Massimiliano Pippi
committed
Oct 22, 2019
1 parent
3aec203
commit c579dc0
Showing
191 changed files
with
62,790 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.operating-system }} | ||
|
||
strategy: | ||
matrix: | ||
operating-system: [ubuntu-latest, windows-latest, macOS-latest] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
|
||
- name: Set Node.js 10.x | ||
uses: actions/setup-node@master | ||
with: | ||
version: 10.x | ||
|
||
- name: npm install | ||
run: npm install | ||
|
||
- name: npm lint | ||
run: npm run format-check | ||
|
||
- name: npm test | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# setup-protoc | ||
|
||
This action makes the `protoc` compiler available to Workflows. | ||
|
||
## Usage | ||
|
||
To get the latest stable version of `protoc` just add this step: | ||
|
||
```yaml | ||
- name: Install Protoc | ||
uses: Arduino/actions/setup-protoc@master | ||
``` | ||
If you want to pin a major or minor version you can use the `.x` wildcard: | ||
|
||
```yaml | ||
- name: Install Protoc | ||
uses: Arduino/actions/setup-protoc@master | ||
with: | ||
version: '3.x' | ||
``` | ||
|
||
You can also require to include releases marked as `pre-release` in Github using the `include-pre-releases` flag (the dafault value for this flag is `false`) | ||
|
||
```yaml | ||
- name: Install Protoc | ||
uses: Arduino/actions/setup-protoc@master | ||
with: | ||
version: '3.x' | ||
include-pre-releases: true | ||
``` | ||
|
||
To pin the exact version: | ||
|
||
```yaml | ||
- name: Install Protoc | ||
uses: Arduino/actions/setup-protoc@master | ||
with: | ||
version: '3.9.1' | ||
``` | ||
|
||
## Development | ||
|
||
To work on the codebase you have to install all the dependencies: | ||
|
||
```sh | ||
# npm install | ||
``` | ||
|
||
To run the tests: | ||
|
||
```sh | ||
# npm run test | ||
``` | ||
|
||
## Enable verbose logging for a pipeline | ||
Additional log events with the prefix ::debug:: can be enabled by setting the secret `ACTIONS_STEP_DEBUG` to `true`. | ||
|
||
See [step-debug-logs](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#step-debug-logs) for reference. | ||
|
||
|
||
|
||
## Release | ||
|
||
We check in the `node_modules` to provide runtime dependencies to the system | ||
using the Action, so be careful not to `git add` all the development dependencies | ||
you might have under your local `node_modules`. To release a new version of the | ||
Action the workflow should be the following: | ||
|
||
1. `npm install` to add all the dependencies, included development. | ||
1. `npm run test` to see everything works as expected. | ||
1. `npm run build` to build the Action under the `./lib` folder. | ||
1. `rm -rf node_modules` to remove all the dependencies. | ||
1. `npm install --production` to add back **only** the runtime dependencies. | ||
1. `git add lib node_modules` to check in the code that matters. | ||
1. open a PR and request a review. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import io = require("@actions/io"); | ||
import path = require("path"); | ||
import os = require("os"); | ||
import fs = require("fs"); | ||
import nock = require("nock"); | ||
|
||
const toolDir = path.join(__dirname, "runner", "tools"); | ||
const tempDir = path.join(__dirname, "runner", "temp"); | ||
const dataDir = path.join(__dirname, "testdata"); | ||
const IS_WINDOWS = process.platform === "win32"; | ||
|
||
process.env["RUNNER_TEMP"] = tempDir; | ||
process.env["RUNNER_TOOL_CACHE"] = toolDir; | ||
import * as installer from "../src/installer"; | ||
|
||
describe("installer tests", () => { | ||
beforeEach(async function() { | ||
await io.rmRF(toolDir); | ||
await io.rmRF(tempDir); | ||
await io.mkdirP(toolDir); | ||
await io.mkdirP(tempDir); | ||
}); | ||
|
||
afterAll(async () => { | ||
try { | ||
await io.rmRF(toolDir); | ||
await io.rmRF(tempDir); | ||
} catch { | ||
console.log("Failed to remove test directories"); | ||
} | ||
}); | ||
|
||
it("Downloads version of protoc if no matching version is installed", async () => { | ||
await installer.getProtoc("3.9.0", true); | ||
const protocDir = path.join(toolDir, "protoc", "3.9.0", os.arch()); | ||
|
||
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true); | ||
|
||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe( | ||
true | ||
); | ||
} else { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true); | ||
} | ||
}, 100000); | ||
|
||
describe("Gets the latest release of protoc", () => { | ||
beforeEach(() => { | ||
nock("https://api.github.com") | ||
.get("/repos/protocolbuffers/protobuf/releases") | ||
.replyWithFile(200, path.join(dataDir, "releases.json")); | ||
}); | ||
|
||
afterEach(() => { | ||
nock.cleanAll(); | ||
nock.enableNetConnect(); | ||
}); | ||
|
||
it("Gets the latest 3.7.x version of protoc using 3.7 and no matching version is installed", async () => { | ||
await installer.getProtoc("3.7", true); | ||
const protocDir = path.join(toolDir, "protoc", "3.7.1", os.arch()); | ||
|
||
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true); | ||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe( | ||
true | ||
); | ||
} else { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true); | ||
} | ||
}, 100000); | ||
|
||
it("Gets latest version of protoc using 3.x and no matching version is installed", async () => { | ||
await installer.getProtoc("3.x", true); | ||
const protocDir = path.join(toolDir, "protoc", "3.9.1", os.arch()); | ||
|
||
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true); | ||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe( | ||
true | ||
); | ||
} else { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true); | ||
} | ||
}, 100000); | ||
}); | ||
|
||
describe("Gets the latest release of protoc with broken latest rc tag", () => { | ||
beforeEach(() => { | ||
nock("https://api.github.com") | ||
.get("/repos/protocolbuffers/protobuf/releases") | ||
.replyWithFile(200, path.join(dataDir, "releases-broken-rc-tag.json")); | ||
}); | ||
|
||
afterEach(() => { | ||
nock.cleanAll(); | ||
nock.enableNetConnect(); | ||
}); | ||
|
||
it("Gets latest version of protoc using 3.x with a broken rc tag, filtering pre-releases", async () => { | ||
await installer.getProtoc("3.x", false); | ||
const protocDir = path.join(toolDir, "protoc", "3.9.1", os.arch()); | ||
|
||
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true); | ||
if (IS_WINDOWS) { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe( | ||
true | ||
); | ||
} else { | ||
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true); | ||
} | ||
}, 100000); | ||
}); | ||
}); |
Oops, something went wrong.