Skip to content

Commit

Permalink
support new protobuf versioning scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed May 26, 2023
1 parent f807b1e commit cb3c120
Show file tree
Hide file tree
Showing 10 changed files with 97,727 additions and 54,382 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@ jobs:
- windows-latest
- macos-latest
version:
- input: 3.x
expected: "libprotoc 3.20.3"
- input: 3.17.x
expected: "libprotoc 3.17.3"
- input: 3.17.2
expected: "libprotoc 3.17.2"
- input: v20.x
expected: "libprotoc 20.5"
- input: v20.5
expected: "libprotoc 20.5"

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run action, using protoc minor version wildcard
- name: Run action, using protoc patch version wildcard
uses: ./
with:
version: '${{ matrix.version.input }}'
Expand All @@ -80,7 +78,7 @@ jobs:
continue-on-error: true
uses: ./
with:
version: 2.42.x
version: 10.x

- name: Fail the job if the action run succeeded
if: steps.setup-task.outcome == 'success'
Expand Down
63 changes: 20 additions & 43 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ describe("installer tests", () => {
});

it("Downloads version of protoc if no matching version is installed", async () => {
await installer.getProtoc("3.9.0", true, GITHUB_TOKEN);
const protocDir = path.join(toolDir, "protoc", "3.9.0", os.arch());
await installer.getProtoc("v23.0", true, GITHUB_TOKEN);
const protocDir = path.join(toolDir, "protoc", "v23.0", os.arch());

expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);

Expand All @@ -79,30 +79,28 @@ describe("installer tests", () => {
nock("https://api.github.com")
.get("/repos/protocolbuffers/protobuf/releases?page=3")
.replyWithFile(200, path.join(dataDir, "releases-3.json"));

nock("https://api.github.com")
.get("/repos/protocolbuffers/protobuf/releases?page=4")
.replyWithFile(200, path.join(dataDir, "releases-4.json"));

nock("https://api.github.com")
.get("/repos/protocolbuffers/protobuf/releases?page=5")
.replyWithFile(200, path.join(dataDir, "releases-5.json"));

nock("https://api.github.com")
.get("/repos/protocolbuffers/protobuf/releases?page=6")
.replyWithFile(200, path.join(dataDir, "releases-6.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, GITHUB_TOKEN);
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, GITHUB_TOKEN);
const protocDir = path.join(toolDir, "protoc", "3.12.4", os.arch());
it("Gets the latest v23.1 version of protoc using v23.1 and no matching version is installed", async () => {
await installer.getProtoc("v23.1", true, GITHUB_TOKEN);
const protocDir = path.join(toolDir, "protoc", "v23.1", os.arch());

expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
Expand All @@ -113,31 +111,10 @@ describe("installer tests", () => {
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?page=1")
.replyWithFile(200, path.join(dataDir, "releases-broken-rc-tag.json"));

nock("https://api.github.com")
.get("/repos/protocolbuffers/protobuf/releases?page=2")
.replyWithFile(200, path.join(dataDir, "releases-2.json"));

nock("https://api.github.com")
.get("/repos/protocolbuffers/protobuf/releases?page=3")
.replyWithFile(200, path.join(dataDir, "releases-3.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());
it("Gets latest version of protoc using v22.x and no matching version is installed", async () => {
await installer.getProtoc("v22.x", true, GITHUB_TOKEN);
const protocDir = path.join(toolDir, "protoc", "v22.5", os.arch());

expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
Expand Down

0 comments on commit cb3c120

Please sign in to comment.