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" ;
6
6
7
7
const toolDir = path . join ( __dirname , "runner" , "tools" ) ;
8
8
const tempDir = path . join ( __dirname , "runner" , "temp" ) ;
@@ -16,19 +16,19 @@ import * as installer from "../src/installer";
16
16
17
17
describe ( "filename tests" , ( ) => {
18
18
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" ] ,
28
28
] ;
29
29
it ( `Downloads all expected versions correctly` , ( ) => {
30
30
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 ) ;
32
32
expect ( expected ) . toBe ( actual ) ;
33
33
}
34
34
} ) ;
@@ -52,8 +52,8 @@ describe("installer tests", () => {
52
52
} ) ;
53
53
54
54
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 ( ) ) ;
57
57
58
58
expect ( fs . existsSync ( `${ protocDir } .complete` ) ) . toBe ( true ) ;
59
59
@@ -79,74 +79,47 @@ describe("installer tests", () => {
79
79
nock ( "https://api.github.com" )
80
80
. get ( "/repos/protocolbuffers/protobuf/releases?page=3" )
81
81
. 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
- } ) ;
117
82
118
- describe ( "Gets the latest release of protoc with broken latest rc tag" , ( ) => {
119
- beforeEach ( ( ) => {
120
83
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" ) ) ;
123
86
124
87
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" ) ) ;
127
90
128
91
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" ) ) ;
131
94
} ) ;
132
95
133
96
afterEach ( ( ) => {
134
97
nock . cleanAll ( ) ;
135
98
nock . enableNetConnect ( ) ;
136
99
} ) ;
137
100
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
+ } ) ;
151
124
} ) ;
152
125
} ) ;
0 commit comments