From ac14d1d0fedd800b475fffde710b8f96055ee1ba Mon Sep 17 00:00:00 2001 From: David Murphy Date: Wed, 11 Dec 2024 11:31:59 -0700 Subject: [PATCH] Updating container usage to reflect that used in new Salt pipelines for CI/CD --- .github/workflows/ci.yml | 10 ++-- .github/workflows/templates/generate.py | 39 ++++++++++----- .github/workflows/test-linux.yml | 63 +++++++++++++++++++++---- 3 files changed, 86 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e88f30f..cfc4d84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,7 +190,7 @@ jobs: with: distro-slug: debian-12 display-name: Debian 12 - container-slug: systemd-debian-12 + container-slug: debian-12 timeout: 20 instances: '["stable-3007", "git-3007", "onedir-3007", "stable-3007-1", "git-master", "latest", "default"]' @@ -205,7 +205,7 @@ jobs: with: distro-slug: photon-5 display-name: Photon OS 5 - container-slug: systemd-photon-5 + container-slug: photon-5 timeout: 20 instances: '["stable-3006", "onedir-3006", "stable-3006-8", "stable-3007", "onedir-3007", "stable-3007-1", "latest", "default"]' @@ -220,7 +220,7 @@ jobs: with: distro-slug: rockylinux-8 display-name: Rocky Linux 8 - container-slug: systemd-rockylinux-8 + container-slug: rockylinux-8 timeout: 20 instances: '["stable-3006", "onedir-3006", "stable-3006-8", "stable-3007", "onedir-3007", "stable-3007-1", "latest", "default"]' @@ -235,7 +235,7 @@ jobs: with: distro-slug: rockylinux-9 display-name: Rocky Linux 9 - container-slug: systemd-rockylinux-9 + container-slug: rockylinux-9 timeout: 20 instances: '["stable-3006", "onedir-3006", "stable-3006-8", "stable-3007", "onedir-3007", "stable-3007-1", "latest", "default"]' @@ -250,7 +250,7 @@ jobs: with: distro-slug: ubuntu-2204 display-name: Ubuntu 22.04 - container-slug: systemd-ubuntu-22.04 + container-slug: ubuntu-22.04 timeout: 20 instances: '["stable-3006", "git-3006", "onedir-3006", "stable-3006-8", "stable-3007", "git-3007", "onedir-3007", "stable-3007-1", "git-master", "latest", "default"]' diff --git a/.github/workflows/templates/generate.py b/.github/workflows/templates/generate.py index ca31b4c..e0ffa35 100755 --- a/.github/workflows/templates/generate.py +++ b/.github/workflows/templates/generate.py @@ -216,20 +216,33 @@ DISTRO_DISPLAY_NAMES = { "windows-2022": "Windows 2022", } +## "amazonlinux-2": "systemd-amazonlinux-2", +## "amazonlinux-2023": "systemd-amazonlinux-2023", +## "debian-11": "systemd-debian-11", +## "debian-12": "systemd-debian-12", +## "debian-13": "systemd-debian-13", +## "fedora-40": "systemd-fedora-40", +## "photon-4": "systemd-photon-4", +## "photon-5": "systemd-photon-5", +## "rockylinux-8": "systemd-rockylinux-8", +## "rockylinux-9": "systemd-rockylinux-9", +## "ubuntu-2004": "systemd-ubuntu-20.04", +## "ubuntu-2204": "systemd-ubuntu-22.04", +## "ubuntu-2404": "systemd-ubuntu-24.04", CONTAINER_SLUG_NAMES = { - "amazonlinux-2": "systemd-amazonlinux-2", - "amazonlinux-2023": "systemd-amazonlinux-2023", - "debian-11": "systemd-debian-11", - "debian-12": "systemd-debian-12", - "debian-13": "systemd-debian-13", - "fedora-40": "systemd-fedora-40", - "photon-4": "systemd-photon-4", - "photon-5": "systemd-photon-5", - "rockylinux-8": "systemd-rockylinux-8", - "rockylinux-9": "systemd-rockylinux-9", - "ubuntu-2004": "systemd-ubuntu-20.04", - "ubuntu-2204": "systemd-ubuntu-22.04", - "ubuntu-2404": "systemd-ubuntu-24.04", + "amazonlinux-2": "amazonlinux-2", + "amazonlinux-2023": "amazonlinux-2023", + "debian-11": "debian-11", + "debian-12": "debian-12", + "debian-13": "debian-13", + "fedora-40": "fedora-40", + "photon-4": "photon-4", + "photon-5": "photon-5", + "rockylinux-8": "rockylinux-8", + "rockylinux-9": "rockylinux-9", + "ubuntu-2004": "ubuntu-20.04", + "ubuntu-2204": "ubuntu-22.04", + "ubuntu-2404": "ubuntu-24.04", "macos-12": "macos-12", "macos-13": "macos-13", "macos-14": "macOS 14", diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 120f23e..0c44d68 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -32,9 +32,9 @@ jobs: Test: name: ${{ matrix.instance }} runs-on: ubuntu-latest - container: - image: ghcr.io/saltstack/salt-ci-containers/testing:${{ inputs.container-slug }} - options: --privileged + ## DGM container: + ## DGM image: ghcr.io/saltstack/salt-ci-containers/testing:${{ inputs.container-slug }} + ## DGM options: --privileged timeout-minutes: ${{ inputs.timeout }} strategy: @@ -46,15 +46,58 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Python Dependencies with pip breakage + ## DGM - name: Install Python Dependencies with pip breakage + ## DGM if: ${{ ( inputs.distro-slug == 'debian-11' ) || ( inputs.distro-slug == 'debian-12' ) || ( inputs.distro-slug == 'debian-13' ) || ( inputs.distro-slug == 'ubuntu-2404' ) }} + ## DGM run: | + ## DGM python3 -m pip install --break-system-packages -r tests/requirements.txt + + ## DGM - name: Install Python Dependencies without pip breakage + ## DGM if: ${{ ( inputs.distro-slug != 'debian-11' ) && ( inputs.distro-slug != 'debian-12' ) && ( inputs.distro-slug != 'debian-13' ) && ( inputs.distro-slug != 'ubuntu-2404' ) }} + ## DGM run: | + ## DGM python3 -m pip install -r tests/requirements.txt + + ## DGM - name: Get Version + ## DGM run: | + ## DGM # We need to get the version here and make it an environment variable + ## DGM # It is used to install via bootstrap and in the test + ## DGM # The version is in the instance name + ## DGM # sed 1st - becomes space, 2nd - becomes dot + ## DGM vt_parm_ver=$(echo "${{ matrix.instance }}" | sed 's/-/ /' | sed 's/-/./' | awk -F ' ' '{print $2}') + ## DGM echo "SaltVersion=$vt_parm_ver" >> $GITHUB_ENV + + ## DGM - name: Bootstrap Salt + ## DGM run: | + ## DGM # sed 1st - becomes space, 2nd - becomes dot + ## DGM bt_arg1=$(echo "${{ matrix.instance }}" | sed 's/-/ /' | sed 's/-/./' | awk -F ' ' '{print $1}') + ## DGM bt_arg2=$(echo "${{ matrix.instance }}" | sed 's/-/ /' | sed 's/-/./' | awk -F ' ' '{print $2}') + ## DGM echo "bt parms ,$bt_parms, bt_arg1 ,$bt_arg1, bt_arg2 ,$bt_arg2," + ## DGM sh -x ./bootstrap-salt.sh "$bt_arg1" "$bt_arg2" + + ## DGM - name: Test Bootstrap + ## DGM run: | + ## DGM pytest --cache-clear -v -s -ra --log-cli-level=debug tests/integration/ + + - name: "Pull container ${{ inputs.container-slug }}" + run: | + docker pull ghcr.io/saltstack/salt-ci-containers/testing:${{ inputs.container-slug }} + + - name: "Create container ${{ inputs.container-slug }}" + run: | + /usr/bin/docker create --name ${{ github.run_id }}_salt-test --workdir /__w/salt/salt --privileged -e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work":"/__w" -v "/home/runner/work/_temp":"/__w/_temp" -v "/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" --entrypoint "/usr/lib/systemd/systemd" ghcr.io/saltstack/salt-ci-containers/testing:${{ inputs.container-slug }} --systemd --unit rescue.target + + - name: "Start container ${{ inputs.container-slug }}" + run: | + /usr/bin/docker start ${{ github.run_id }}_salt-test + + - name: "Install Python Dependencies with pip breakage in container ${{ inputs.container-slug }}" if: ${{ ( inputs.distro-slug == 'debian-11' ) || ( inputs.distro-slug == 'debian-12' ) || ( inputs.distro-slug == 'debian-13' ) || ( inputs.distro-slug == 'ubuntu-2404' ) }} run: | python3 -m pip install --break-system-packages -r tests/requirements.txt - - name: Install Python Dependencies without pip breakage + - name: "Install Python Dependencies without pip breakage in container ${{ inputs.container-slug }}" if: ${{ ( inputs.distro-slug != 'debian-11' ) && ( inputs.distro-slug != 'debian-12' ) && ( inputs.distro-slug != 'debian-13' ) && ( inputs.distro-slug != 'ubuntu-2404' ) }} run: | - python3 -m pip install -r tests/requirements.txt + docker exec ${{ github.run_id}}_salt-test python3 -m pip install -r tests/requirements.txt - name: Get Version run: | @@ -65,17 +108,21 @@ jobs: vt_parm_ver=$(echo "${{ matrix.instance }}" | sed 's/-/ /' | sed 's/-/./' | awk -F ' ' '{print $2}') echo "SaltVersion=$vt_parm_ver" >> $GITHUB_ENV + - name: Current Directory + run: | + pwd + - name: Bootstrap Salt run: | # sed 1st - becomes space, 2nd - becomes dot bt_arg1=$(echo "${{ matrix.instance }}" | sed 's/-/ /' | sed 's/-/./' | awk -F ' ' '{print $1}') bt_arg2=$(echo "${{ matrix.instance }}" | sed 's/-/ /' | sed 's/-/./' | awk -F ' ' '{print $2}') echo "bt parms ,$bt_parms, bt_arg1 ,$bt_arg1, bt_arg2 ,$bt_arg2," - sh -x ./bootstrap-salt.sh "$bt_arg1" "$bt_arg2" + docker exec ${{ github.run_id}}_salt-test sh -x ./bootstrap-salt.sh "$bt_arg1" "$bt_arg2" - name: Test Bootstrap run: | - pytest --cache-clear -v -s -ra --log-cli-level=debug tests/integration/ + docker exec ${{ github.run_id}}_salt-test pytest --cache-clear -v -s -ra --log-cli-level=debug tests/integration/ - name: Set Exit Status if: always()