Skip to content

Commit 28fd3e5

Browse files
Support only the new protobuf versioning scheme (#78)
1 parent 149f6c8 commit 28fd3e5

File tree

11 files changed

+97759
-54434
lines changed

11 files changed

+97759
-54434
lines changed

.github/workflows/test-integration.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,16 @@ jobs:
4646
- windows-latest
4747
- macos-latest
4848
version:
49-
- input: 3.x
50-
expected: "libprotoc 3.20.3"
51-
- input: 3.17.x
52-
expected: "libprotoc 3.17.3"
53-
- input: 3.17.2
54-
expected: "libprotoc 3.17.2"
49+
- input: v22.x
50+
expected: "libprotoc 22.5"
51+
- input: v22.3
52+
expected: "libprotoc 22.3"
5553

5654
steps:
5755
- name: Checkout repository
5856
uses: actions/checkout@v3
5957

60-
- name: Run action, using protoc minor version wildcard
58+
- name: Run action, using protoc patch version wildcard
6159
uses: ./
6260
with:
6361
version: '${{ matrix.version.input }}'
@@ -80,7 +78,7 @@ jobs:
8078
continue-on-error: true
8179
uses: ./
8280
with:
83-
version: 2.42.x
81+
version: v10.x
8482

8583
- name: Fail the job if the action run succeeded
8684
if: steps.setup-task.outcome == 'success'

__tests__/main.test.ts

+46-73
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import io = require("@actions/io");
2-
import path = require("path");
3-
import os = require("os");
4-
import fs = require("fs");
5-
import nock = require("nock");
1+
import * as io from "@actions/io";
2+
import * as path from "path";
3+
import * as os from "os";
4+
import * as fs from "fs";
5+
import nock from "nock";
66

77
const toolDir = path.join(__dirname, "runner", "tools");
88
const tempDir = path.join(__dirname, "runner", "temp");
@@ -16,19 +16,19 @@ import * as installer from "../src/installer";
1616

1717
describe("filename tests", () => {
1818
const tests = [
19-
["protoc-3.20.2-linux-x86_32.zip", "linux", ""],
20-
["protoc-3.20.2-linux-x86_64.zip", "linux", "x64"],
21-
["protoc-3.20.2-linux-aarch_64.zip", "linux", "arm64"],
22-
["protoc-3.20.2-linux-ppcle_64.zip", "linux", "ppc64"],
23-
["protoc-3.20.2-linux-s390_64.zip", "linux", "s390x"],
24-
["protoc-3.20.2-osx-aarch_64.zip", "darwin", "arm64"],
25-
["protoc-3.20.2-osx-x86_64.zip", "darwin", "x64"],
26-
["protoc-3.20.2-win64.zip", "win32", "x64"],
27-
["protoc-3.20.2-win32.zip", "win32", "x32"],
19+
["protoc-23.2-linux-x86_32.zip", "linux", ""],
20+
["protoc-23.2-linux-x86_64.zip", "linux", "x64"],
21+
["protoc-23.2-linux-aarch_64.zip", "linux", "arm64"],
22+
["protoc-23.2-linux-ppcle_64.zip", "linux", "ppc64"],
23+
["protoc-23.2-linux-s390_64.zip", "linux", "s390x"],
24+
["protoc-23.2-osx-aarch_64.zip", "darwin", "arm64"],
25+
["protoc-23.2-osx-x86_64.zip", "darwin", "x64"],
26+
["protoc-23.2-win64.zip", "win32", "x64"],
27+
["protoc-23.2-win32.zip", "win32", "x32"],
2828
];
2929
it(`Downloads all expected versions correctly`, () => {
3030
for (const [expected, plat, arch] of tests) {
31-
const actual = installer.getFileName("3.20.2", plat, arch);
31+
const actual = installer.getFileName("23.2", plat, arch);
3232
expect(expected).toBe(actual);
3333
}
3434
});
@@ -52,8 +52,8 @@ describe("installer tests", () => {
5252
});
5353

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

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

@@ -79,74 +79,47 @@ describe("installer tests", () => {
7979
nock("https://api.github.com")
8080
.get("/repos/protocolbuffers/protobuf/releases?page=3")
8181
.replyWithFile(200, path.join(dataDir, "releases-3.json"));
82-
});
83-
84-
afterEach(() => {
85-
nock.cleanAll();
86-
nock.enableNetConnect();
87-
});
88-
89-
it("Gets the latest 3.7.x version of protoc using 3.7 and no matching version is installed", async () => {
90-
await installer.getProtoc("3.7", true, GITHUB_TOKEN);
91-
const protocDir = path.join(toolDir, "protoc", "3.7.1", os.arch());
92-
93-
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
94-
if (IS_WINDOWS) {
95-
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe(
96-
true
97-
);
98-
} else {
99-
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true);
100-
}
101-
}, 100000);
102-
103-
it("Gets latest version of protoc using 3.x and no matching version is installed", async () => {
104-
await installer.getProtoc("3.x", true, GITHUB_TOKEN);
105-
const protocDir = path.join(toolDir, "protoc", "3.12.4", os.arch());
106-
107-
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
108-
if (IS_WINDOWS) {
109-
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe(
110-
true
111-
);
112-
} else {
113-
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true);
114-
}
115-
}, 100000);
116-
});
11782

118-
describe("Gets the latest release of protoc with broken latest rc tag", () => {
119-
beforeEach(() => {
12083
nock("https://api.github.com")
121-
.get("/repos/protocolbuffers/protobuf/releases?page=1")
122-
.replyWithFile(200, path.join(dataDir, "releases-broken-rc-tag.json"));
84+
.get("/repos/protocolbuffers/protobuf/releases?page=4")
85+
.replyWithFile(200, path.join(dataDir, "releases-4.json"));
12386

12487
nock("https://api.github.com")
125-
.get("/repos/protocolbuffers/protobuf/releases?page=2")
126-
.replyWithFile(200, path.join(dataDir, "releases-2.json"));
88+
.get("/repos/protocolbuffers/protobuf/releases?page=5")
89+
.replyWithFile(200, path.join(dataDir, "releases-5.json"));
12790

12891
nock("https://api.github.com")
129-
.get("/repos/protocolbuffers/protobuf/releases?page=3")
130-
.replyWithFile(200, path.join(dataDir, "releases-3.json"));
92+
.get("/repos/protocolbuffers/protobuf/releases?page=6")
93+
.replyWithFile(200, path.join(dataDir, "releases-6.json"));
13194
});
13295

13396
afterEach(() => {
13497
nock.cleanAll();
13598
nock.enableNetConnect();
13699
});
137100

138-
it("Gets latest version of protoc using 3.x with a broken rc tag, filtering pre-releases", async () => {
139-
await installer.getProtoc("3.x", false, "");
140-
const protocDir = path.join(toolDir, "protoc", "3.9.1", os.arch());
141-
142-
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
143-
if (IS_WINDOWS) {
144-
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe(
145-
true
146-
);
147-
} else {
148-
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true);
149-
}
150-
}, 100000);
101+
const tests = [
102+
["v23.1", "v23.1"],
103+
["v22.x", "v22.5"],
104+
["v23.0-rc2", "v23.0-rc2"],
105+
];
106+
tests.forEach(function (testCase) {
107+
const [input, expected] = testCase;
108+
it(`Gets latest version of protoc using ${input} and no matching version is installed`, async () => {
109+
await installer.getProtoc(input, true, GITHUB_TOKEN);
110+
const protocDir = path.join(toolDir, "protoc", expected, os.arch());
111+
112+
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
113+
if (IS_WINDOWS) {
114+
expect(fs.existsSync(path.join(protocDir, "bin", "protoc.exe"))).toBe(
115+
true
116+
);
117+
} else {
118+
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(
119+
true
120+
);
121+
}
122+
}, 100000);
123+
});
151124
});
152125
});

0 commit comments

Comments
 (0)