Skip to content

Commit 825fbe0

Browse files
support new protobuf versioning scheme
1 parent 81936f9 commit 825fbe0

File tree

11 files changed

+97742
-54398
lines changed

11 files changed

+97742
-54398
lines changed

.github/workflows/test-integration.yml

Lines changed: 6 additions & 8 deletions
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.5
52+
expected: "libprotoc 22.5"
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

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -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,30 +79,28 @@ 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+
nock("https://api.github.com")
84+
.get("/repos/protocolbuffers/protobuf/releases?page=4")
85+
.replyWithFile(200, path.join(dataDir, "releases-4.json"));
86+
87+
nock("https://api.github.com")
88+
.get("/repos/protocolbuffers/protobuf/releases?page=5")
89+
.replyWithFile(200, path.join(dataDir, "releases-5.json"));
90+
91+
nock("https://api.github.com")
92+
.get("/repos/protocolbuffers/protobuf/releases?page=6")
93+
.replyWithFile(200, path.join(dataDir, "releases-6.json"));
8294
});
8395

8496
afterEach(() => {
8597
nock.cleanAll();
8698
nock.enableNetConnect();
8799
});
88100

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());
101+
it("Gets the latest v23.1 version of protoc using v23.1 and no matching version is installed", async () => {
102+
await installer.getProtoc("v23.1", true, GITHUB_TOKEN);
103+
const protocDir = path.join(toolDir, "protoc", "v23.1", os.arch());
106104

107105
expect(fs.existsSync(`${protocDir}.complete`)).toBe(true);
108106
if (IS_WINDOWS) {
@@ -113,31 +111,10 @@ describe("installer tests", () => {
113111
expect(fs.existsSync(path.join(protocDir, "bin", "protoc"))).toBe(true);
114112
}
115113
}, 100000);
116-
});
117-
118-
describe("Gets the latest release of protoc with broken latest rc tag", () => {
119-
beforeEach(() => {
120-
nock("https://api.github.com")
121-
.get("/repos/protocolbuffers/protobuf/releases?page=1")
122-
.replyWithFile(200, path.join(dataDir, "releases-broken-rc-tag.json"));
123-
124-
nock("https://api.github.com")
125-
.get("/repos/protocolbuffers/protobuf/releases?page=2")
126-
.replyWithFile(200, path.join(dataDir, "releases-2.json"));
127-
128-
nock("https://api.github.com")
129-
.get("/repos/protocolbuffers/protobuf/releases?page=3")
130-
.replyWithFile(200, path.join(dataDir, "releases-3.json"));
131-
});
132-
133-
afterEach(() => {
134-
nock.cleanAll();
135-
nock.enableNetConnect();
136-
});
137114

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());
115+
it("Gets latest version of protoc using v22.x and no matching version is installed", async () => {
116+
await installer.getProtoc("v22.x", true, GITHUB_TOKEN);
117+
const protocDir = path.join(toolDir, "protoc", "v22.5", os.arch());
141118

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

0 commit comments

Comments
 (0)