Skip to content

Commit f684803

Browse files
committed
feat: support for Ubuntu 22.04
1 parent 1f246d6 commit f684803

File tree

3 files changed

+54
-19
lines changed

3 files changed

+54
-19
lines changed

.github/workflows/runner.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ on:
99
jobs:
1010
default-inputs:
1111
name: Run with defaults
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
strategy:
1414
matrix:
15-
kubernetes: [v1.24.1,v1.23.0,v1.20.0,v1.19.2,v1.18.9,v1.17.5]
15+
kubernetes: [v1.24.3,v1.23.9,v1.22.12]
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v2
@@ -21,7 +21,7 @@ jobs:
2121
- name: Test Action
2222
uses: ./
2323
with:
24-
minikube version: v1.26.0
24+
minikube version: v1.26.1
2525
kubernetes version: ${{ matrix.kubernetes }}
2626
github token: ${{ secrets.GITHUB_TOKEN }}
2727
- name: Validate Minikube
@@ -41,8 +41,8 @@ jobs:
4141
- name: Test Action
4242
uses: ./
4343
with:
44-
minikube version: v1.26.0
45-
kubernetes version: v1.24.1
44+
minikube version: v1.26.1
45+
kubernetes version: v1.24.3
4646
github token: ${{ secrets.GITHUB_TOKEN }}
4747
driver: docker
4848
- name: Validate Minikube
@@ -64,8 +64,8 @@ jobs:
6464
- name: Test Action
6565
uses: ./
6666
with:
67-
minikube version: v1.26.0
68-
kubernetes version: v1.24.1
67+
minikube version: v1.26.1
68+
kubernetes version: v1.24.3
6969
github token: ${{ secrets.GITHUB_TOKEN }}
7070
start args: '--addons=registry --addons=metrics-server'
7171
- name: Validate Minikube
@@ -85,8 +85,8 @@ jobs:
8585
- name: Test Action
8686
uses: ./
8787
with:
88-
minikube version: v1.26.0
89-
kubernetes version: v1.24.1
88+
minikube version: v1.26.1
89+
kubernetes version: v1.24.3
9090
github token: ${{ secrets.GITHUB_TOKEN }}
9191
start args: '--addons=ingress'
9292
- name: Validate Minikube
@@ -121,8 +121,31 @@ jobs:
121121
run: kubectl get nodes
122122
- name: Validate container runtime (${{ matrix.container_runtime }})
123123
run: 'cat $MINIKUBE_HOME/.minikube/machines/minikube/config.json | jq ".Driver.NodeConfig.ContainerRuntime" | grep "${{ matrix.container_runtime }}"'
124-
legacy:
125-
name: Run for legacy/old versions
124+
unsupported:
125+
name: Run with unsupported K8s versions
126+
runs-on: ubuntu-20.04
127+
strategy:
128+
matrix:
129+
kubernetes: [v1.20.15,v1.19.16,v1.18.20,v1.17.17]
130+
steps:
131+
- name: Checkout
132+
uses: actions/checkout@v2
133+
- name: Setup Node
134+
uses: actions/setup-node@master
135+
- name: Test Action
136+
uses: ./
137+
with:
138+
minikube version: v1.26.0
139+
kubernetes version: ${{ matrix.kubernetes }}
140+
github token: ${{ secrets.GITHUB_TOKEN }}
141+
- name: Validate Minikube
142+
run: minikube status | grep Running
143+
- name: Validate Cluster
144+
run: kubectl get nodes
145+
- name: Validate default driver
146+
run: 'cat $MINIKUBE_HOME/.minikube/machines/minikube/config.json | jq ".DriverName" | grep none'
147+
legacy-18:
148+
name: Run for legacy/old versions (Ubuntu 18, Minikube 1.16, K8s 1.12)
126149
runs-on: ubuntu-18.04
127150
steps:
128151
- name: Checkout

src/__tests__/check-environment.test.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('check-environment module test suite', () => {
1414
process.platform = 'win32';
1515
// When - Then
1616
expect(checkEnvironment).toThrow(
17-
'Unsupported OS, action only works in Ubuntu 18'
17+
'Unsupported OS, action only works in Ubuntu 18, 20, or 22'
1818
);
1919
});
2020
test('OS is Linux but not Ubuntu, should throw Error', () => {
@@ -24,7 +24,7 @@ describe('check-environment module test suite', () => {
2424
fs.readFileSync.mockImplementation(() => 'SOME DIFFERENT OS');
2525
// When - Then
2626
expect(checkEnvironment).toThrow(
27-
'Unsupported OS, action only works in Ubuntu 18'
27+
'Unsupported OS, action only works in Ubuntu 18, 20, or 22'
2828
);
2929
expect(fs.existsSync).toHaveBeenCalled();
3030
expect(fs.readFileSync).toHaveBeenCalledTimes(0);
@@ -36,7 +36,7 @@ describe('check-environment module test suite', () => {
3636
fs.readFileSync.mockImplementation(() => 'SOME DIFFERENT OS');
3737
// When - Then
3838
expect(checkEnvironment).toThrow(
39-
'Unsupported OS, action only works in Ubuntu 18'
39+
'Unsupported OS, action only works in Ubuntu 18, 20, or 22'
4040
);
4141
expect(fs.existsSync).toHaveBeenCalled();
4242
expect(fs.readFileSync).toHaveBeenCalled();
@@ -67,5 +67,18 @@ describe('check-environment module test suite', () => {
6767
// When - Then
6868
expect(checkEnvironment).not.toThrow();
6969
});
70+
test('OS is Linux and Ubuntu 22, should not throw Error', () => {
71+
// Given
72+
Object.defineProperty(process, 'platform', {value: 'linux'});
73+
fs.existsSync.mockImplementation(() => true);
74+
fs.readFileSync.mockImplementation(
75+
() => `
76+
NAME="Ubuntu"
77+
VERSION="22.04.1 LTS (Jammy Jellyfish)"
78+
`
79+
);
80+
// When - Then
81+
expect(checkEnvironment).not.toThrow();
82+
});
7083
});
7184
});

src/check-environment.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const fs = require('fs');
44

55
const isLinux = () => process.platform.toLowerCase().indexOf('linux') === 0;
6-
const isUbuntu = version => {
6+
const isUbuntu = version => () => {
77
const osRelease = '/etc/os-release';
88
const osInfo = fs.existsSync(osRelease) && fs.readFileSync(osRelease);
99
return (
@@ -12,12 +12,11 @@ const isUbuntu = version => {
1212
osInfo.indexOf(`VERSION="${version}`) >= 0
1313
);
1414
};
15-
const isUbuntu18 = () => isUbuntu('18');
16-
const isUbuntu20 = () => isUbuntu('20');
17-
const isValidLinux = () => isLinux() && (isUbuntu18() || isUbuntu20());
15+
['18', '20', '22'].some(v => isUbuntu(v)())
16+
const isValidLinux = () => isLinux() && ['18', '20', '22'].some(v => isUbuntu(v)());
1817
const checkOperatingSystem = () => {
1918
if (!isValidLinux()) {
20-
throw Error('Unsupported OS, action only works in Ubuntu 18 or 20');
19+
throw Error('Unsupported OS, action only works in Ubuntu 18, 20, or 22');
2120
}
2221
};
2322

0 commit comments

Comments
 (0)