diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bb2f2c..5ca1c06 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,6 +99,27 @@ jobs: #- macos-14 # no virt: https://github.com/docker/actions-toolkit/issues/317 - macos-13 - windows-latest + includes: + - os: macos-13 + test: docker/install.test.itg.ts + docker_install_type: image + docker_install_version: 27.3.1 + - os: macos-13 + test: docker/install.test.itg.ts + docker_install_type: image + docker_install_version: master + - os: macos-13 + test: docker/install.test.itg.ts + docker_install_type: image + docker_install_version: latest + - os: macos-13 + test: docker/install.test.itg.ts + docker_install_type: archive + docker_install_version: v26.1.4 + - os: macos-13 + test: docker/install.test.itg.ts + docker_install_type: archive + docker_install_version: latest steps: - name: Checkout @@ -151,6 +172,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }} TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }} + DOCKER_INSTALL_TYPE: ${{ matrix.docker_install_type }} + DOCKER_INSTALL_VERSION: ${{ matrix.docker_install_version }} - name: Check coverage run: | diff --git a/__tests__/docker/install.test.itg.ts b/__tests__/docker/install.test.itg.ts index b960e77..9581966 100644 --- a/__tests__/docker/install.test.itg.ts +++ b/__tests__/docker/install.test.itg.ts @@ -14,18 +14,21 @@ * limitations under the License. */ -import {jest, describe, test, beforeEach, afterEach, expect} from '@jest/globals'; +import {jest, describe, beforeEach, afterEach, expect, it} from '@jest/globals'; import fs from 'fs'; import os from 'os'; import path from 'path'; -import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install'; +import {Install, InstallSource, InstallSourceArchive, InstallSourceImage} from '../../src/docker/install'; import {Docker} from '../../src/docker/docker'; import {Exec} from '../../src/exec'; +const dockerInstallType = process.env.DOCKER_INSTALL_TYPE || 'archive'; +const dockerInstallVersion = process.env.DOCKER_INSTALL_VERSION || 'latest'; + const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-')); -describe('install', () => { +describe('root', () => { const originalEnv = process.env; beforeEach(() => { jest.resetModules(); @@ -39,41 +42,26 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g afterEach(() => { process.env = originalEnv; }); - // prettier-ignore - test.each([ - {type: 'image', tag: '27.3.1'} as InstallSourceImage, - {type: 'image', tag: 'master'} as InstallSourceImage, - {type: 'image', tag: 'latest'} as InstallSourceImage, - {type: 'archive', version: 'v26.1.4', channel: 'stable'} as InstallSourceArchive, - {type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive, - ])( - 'install docker %s', async (source) => { + it( + 'install docker', + async () => { await ensureNoSystemContainerd(); const install = new Install({ - source: source, + source: getSource(), runDir: tmpDir(), contextName: 'foo', daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}` }); await expect(tryInstall(install)).resolves.not.toThrow(); - }, 30 * 60 * 1000); -}); - -describe('rootless', () => { - // prettier-ignore - test.each([ - {type: 'image', tag: 'latest'} as InstallSourceImage, - {type: 'archive', version: 'latest', channel: 'stable'} as InstallSourceArchive, - ])( - 'install %s', async (source) => { - // Skip on non linux - if (os.platform() !== 'linux') { - return; - } - + }, + 30 * 60 * 1000 + ); + it( + 'install rootless docker', + async () => { await ensureNoSystemContainerd(); const install = new Install({ - source: source, + source: getSource(), runDir: tmpDir(), contextName: 'foo', daemonConfig: `{"debug":true}`, @@ -122,3 +110,17 @@ async function ensureNoSystemContainerd() { }); } } + +function getSource(): InstallSource { + if (dockerInstallType === 'archive') { + return { + version: dockerInstallVersion, + channel: 'stable' + } as InstallSourceArchive; + } else { + return { + type: dockerInstallType, + tag: dockerInstallVersion + } as InstallSourceImage; + } +}