-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: podman install ci tests by container matrix
- Loading branch information
Showing
17 changed files
with
246 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Podman Install on Linux Distros | ||
on: | ||
push: | ||
# branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
container-test-job: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
container: [ | ||
"ubuntu:24", | ||
"ubuntu:23", | ||
"ubuntu:22", | ||
"debian:12", | ||
"fedora:40", | ||
"fedora:39" | ||
] | ||
|
||
container: | ||
image: ${{ matrix.container }} | ||
env: | ||
NODE_ENV: test | ||
steps: | ||
- name: print os version details | ||
run: cat /etc/os-release | ||
|
||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: 🧱 Install Dependencies | ||
run: | | ||
npm ci | ||
- name: 🧱 Run tests | ||
run: | | ||
npm run testCi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { execSync } from 'node:child_process'; | ||
import { beforeAll, describe, expect, it, vi } from 'vitest'; | ||
import { isLinux } from '../../main/platform.js'; | ||
import { | ||
PODMAN_MIN_VERSION, | ||
getInstalledPodmanVersion, | ||
} from '../../main/podman/install/install.js'; | ||
// import installPodman from '../../main/podman/install/install.js'; | ||
import installOnLinux from '../../main/podman/install/installOnLinux.js'; | ||
import uninstallOnLinux from '../../main/podman/uninstall/uninstallOnLinux.js'; | ||
|
||
beforeAll(async () => { | ||
// called once before all tests run | ||
if (!isLinux()) { | ||
throw new Error('This test suite is only for Linux'); | ||
} | ||
|
||
vi.mock('../../main/logger.js', () => { | ||
return { | ||
default: { | ||
info: vi.fn((msg: string) => { | ||
console.log(msg); | ||
}), | ||
error: vi.fn((msg: string) => { | ||
console.log(msg); | ||
}), | ||
}, | ||
autoUpdateLogger: vi.fn(), | ||
}; | ||
}); | ||
|
||
vi.mock('../../main/execHelper.js', () => { | ||
return { | ||
execAwait: vi.fn((command: string) => { | ||
return execSync(command); | ||
}), | ||
}; | ||
}); | ||
|
||
vi.mock('electron', () => { | ||
return { | ||
app: { | ||
getAppPath: vi.fn(() => { | ||
return '/we/out/here/nice-node'; | ||
}), | ||
getPath: vi.fn((pathName: string) => { | ||
return pathName; | ||
}), | ||
isPackaged: false, | ||
on: vi.fn(), | ||
getName: () => 'NiceNode', | ||
}, | ||
powerMonitor: { | ||
isOnBatteryPower: vi.fn(), | ||
}, | ||
autoUpdater: vi.fn(), | ||
nativeTheme: { | ||
on: vi.fn(), | ||
}, | ||
}; | ||
}); | ||
vi.mock('@sentry/electron/main', () => { | ||
return { | ||
init: vi.fn(() => { | ||
return {}; | ||
}), | ||
}; | ||
}); | ||
vi.mock('../../main/i18nMain', () => { | ||
return { | ||
default: { | ||
// Mock any other properties or methods if needed | ||
getFixedT: vi.fn((x, y) => { | ||
return { | ||
t: (k: any) => k, // just return the key for simplicity | ||
}; | ||
}), | ||
}, | ||
// changeLanguage: vi.fn(), | ||
// init: vi.fn(), | ||
// use: vi.fn(() => i18nMock), // for chaining .use() calls | ||
}; | ||
}); | ||
}); | ||
const versionRegex = /(\d+\.\d+\.\d+)/; | ||
|
||
describe.sequential('Install and Uninstall Podman', () => { | ||
it('If pre-installed, uninstall to test install next', async () => { | ||
const versionBefore = await getInstalledPodmanVersion(); | ||
if (versionBefore !== undefined) { | ||
expect(versionBefore).toMatch(versionRegex); | ||
const resultInstall = await uninstallOnLinux(); | ||
expect(resultInstall).toEqual(true); | ||
const versionAfter = await getInstalledPodmanVersion(); | ||
expect(versionAfter).toBeUndefined(); | ||
} | ||
}); | ||
|
||
it('Install is successful and returns true', async () => { | ||
const versionBefore = await getInstalledPodmanVersion(); | ||
expect(versionBefore).toBeUndefined(); | ||
const resultInstall = await installOnLinux(); | ||
expect(resultInstall).toEqual(true); | ||
const versionAfter = await getInstalledPodmanVersion(); | ||
expect(versionAfter).toMatch(versionRegex); | ||
expect(versionAfter > PODMAN_MIN_VERSION).toBeTruthy(); | ||
}, 20000); // 20 seconds timeout | ||
|
||
it('Uninstall is successful and returns true', async () => { | ||
const versionBefore = await getInstalledPodmanVersion(); | ||
expect(versionBefore).toMatch(versionRegex); | ||
expect(versionBefore > PODMAN_MIN_VERSION).toBeTruthy(); | ||
// expect(versionBefore).toEqual('4.3.1'); | ||
const resultInstall = await uninstallOnLinux(); | ||
expect(resultInstall).toEqual(true); | ||
const versionAfter = await getInstalledPodmanVersion(); | ||
expect(versionAfter).toBeUndefined(); | ||
}); | ||
// check not installed before | ||
// version? | ||
// it('Is successful and returns true', async () => { | ||
// const resultInstall = await installPodman(); | ||
// expect(resultInstall).toEqual(true); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,4 @@ | ||
// Same script as on https://podman.io/docs/installation, except the 'sudo' is removed as | ||
// sudo-prompt will not execute a command with sudo | ||
export const script = `apt-get -y update -qq | ||
apt-get -y install curl | ||
mkdir -p /etc/apt/keyrings | ||
curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/Debian_Unstable/Release.key \ | ||
| gpg --dearmor \ | ||
| tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ | ||
https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/Debian_Unstable/ /" \ | ||
| tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null | ||
apt-get -y update | ||
apt-get -y upgrade | ||
apt-get -y install podman`; | ||
// Reference https://podman.io/docs/installation | ||
export const script = `rm -rf /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list | ||
apt -y update -qq | ||
apt install -y podman`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
// Same script as on https://podman.io/docs/installation, except the 'sudo' is removed as | ||
// sudo-prompt will not execute a command with sudo | ||
export const script = `apt-get -y update -qq | ||
apt-get -y -qq install curl | ||
mkdir -p /etc/apt/keyrings | ||
curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04/Release.key \ | ||
| gpg --dearmor \ | ||
| tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ | ||
https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04/ /" \ | ||
| tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null | ||
apt-get update -qq | ||
apt-get -qq -y install podman`; | ||
// Reference https://podman.io/docs/installation | ||
export const script = `rm -rf /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list | ||
apt -y update -qq | ||
apt install -y podman`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const script = `rm -rf /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list | ||
apt remove -y podman`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const script = 'dnf remove -y podman'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const script = 'yum remove -y podman'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.