Skip to content

Commit

Permalink
feat: support for Ubuntu 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed Aug 8, 2022
1 parent 1f246d6 commit f684803
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 19 deletions.
45 changes: 34 additions & 11 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
default-inputs:
name: Run with defaults
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
kubernetes: [v1.24.1,v1.23.0,v1.20.0,v1.19.2,v1.18.9,v1.17.5]
kubernetes: [v1.24.3,v1.23.9,v1.22.12]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -21,7 +21,7 @@ jobs:
- name: Test Action
uses: ./
with:
minikube version: v1.26.0
minikube version: v1.26.1
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Minikube
Expand All @@ -41,8 +41,8 @@ jobs:
- name: Test Action
uses: ./
with:
minikube version: v1.26.0
kubernetes version: v1.24.1
minikube version: v1.26.1
kubernetes version: v1.24.3
github token: ${{ secrets.GITHUB_TOKEN }}
driver: docker
- name: Validate Minikube
Expand All @@ -64,8 +64,8 @@ jobs:
- name: Test Action
uses: ./
with:
minikube version: v1.26.0
kubernetes version: v1.24.1
minikube version: v1.26.1
kubernetes version: v1.24.3
github token: ${{ secrets.GITHUB_TOKEN }}
start args: '--addons=registry --addons=metrics-server'
- name: Validate Minikube
Expand All @@ -85,8 +85,8 @@ jobs:
- name: Test Action
uses: ./
with:
minikube version: v1.26.0
kubernetes version: v1.24.1
minikube version: v1.26.1
kubernetes version: v1.24.3
github token: ${{ secrets.GITHUB_TOKEN }}
start args: '--addons=ingress'
- name: Validate Minikube
Expand Down Expand Up @@ -121,8 +121,31 @@ jobs:
run: kubectl get nodes
- name: Validate container runtime (${{ matrix.container_runtime }})
run: 'cat $MINIKUBE_HOME/.minikube/machines/minikube/config.json | jq ".Driver.NodeConfig.ContainerRuntime" | grep "${{ matrix.container_runtime }}"'
legacy:
name: Run for legacy/old versions
unsupported:
name: Run with unsupported K8s versions
runs-on: ubuntu-20.04
strategy:
matrix:
kubernetes: [v1.20.15,v1.19.16,v1.18.20,v1.17.17]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@master
- name: Test Action
uses: ./
with:
minikube version: v1.26.0
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Minikube
run: minikube status | grep Running
- name: Validate Cluster
run: kubectl get nodes
- name: Validate default driver
run: 'cat $MINIKUBE_HOME/.minikube/machines/minikube/config.json | jq ".DriverName" | grep none'
legacy-18:
name: Run for legacy/old versions (Ubuntu 18, Minikube 1.16, K8s 1.12)
runs-on: ubuntu-18.04
steps:
- name: Checkout
Expand Down
19 changes: 16 additions & 3 deletions src/__tests__/check-environment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('check-environment module test suite', () => {
process.platform = 'win32';
// When - Then
expect(checkEnvironment).toThrow(
'Unsupported OS, action only works in Ubuntu 18'
'Unsupported OS, action only works in Ubuntu 18, 20, or 22'
);
});
test('OS is Linux but not Ubuntu, should throw Error', () => {
Expand All @@ -24,7 +24,7 @@ describe('check-environment module test suite', () => {
fs.readFileSync.mockImplementation(() => 'SOME DIFFERENT OS');
// When - Then
expect(checkEnvironment).toThrow(
'Unsupported OS, action only works in Ubuntu 18'
'Unsupported OS, action only works in Ubuntu 18, 20, or 22'
);
expect(fs.existsSync).toHaveBeenCalled();
expect(fs.readFileSync).toHaveBeenCalledTimes(0);
Expand All @@ -36,7 +36,7 @@ describe('check-environment module test suite', () => {
fs.readFileSync.mockImplementation(() => 'SOME DIFFERENT OS');
// When - Then
expect(checkEnvironment).toThrow(
'Unsupported OS, action only works in Ubuntu 18'
'Unsupported OS, action only works in Ubuntu 18, 20, or 22'
);
expect(fs.existsSync).toHaveBeenCalled();
expect(fs.readFileSync).toHaveBeenCalled();
Expand Down Expand Up @@ -67,5 +67,18 @@ describe('check-environment module test suite', () => {
// When - Then
expect(checkEnvironment).not.toThrow();
});
test('OS is Linux and Ubuntu 22, should not throw Error', () => {
// Given
Object.defineProperty(process, 'platform', {value: 'linux'});
fs.existsSync.mockImplementation(() => true);
fs.readFileSync.mockImplementation(
() => `
NAME="Ubuntu"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
`
);
// When - Then
expect(checkEnvironment).not.toThrow();
});
});
});
9 changes: 4 additions & 5 deletions src/check-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs');

const isLinux = () => process.platform.toLowerCase().indexOf('linux') === 0;
const isUbuntu = version => {
const isUbuntu = version => () => {
const osRelease = '/etc/os-release';
const osInfo = fs.existsSync(osRelease) && fs.readFileSync(osRelease);
return (
Expand All @@ -12,12 +12,11 @@ const isUbuntu = version => {
osInfo.indexOf(`VERSION="${version}`) >= 0
);
};
const isUbuntu18 = () => isUbuntu('18');
const isUbuntu20 = () => isUbuntu('20');
const isValidLinux = () => isLinux() && (isUbuntu18() || isUbuntu20());
['18', '20', '22'].some(v => isUbuntu(v)())
const isValidLinux = () => isLinux() && ['18', '20', '22'].some(v => isUbuntu(v)());
const checkOperatingSystem = () => {
if (!isValidLinux()) {
throw Error('Unsupported OS, action only works in Ubuntu 18 or 20');
throw Error('Unsupported OS, action only works in Ubuntu 18, 20, or 22');
}
};

Expand Down

0 comments on commit f684803

Please sign in to comment.