From 957032d7855f37593c3970007a5ae442d53fb65d Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Tue, 24 Jan 2023 16:25:00 +0000 Subject: [PATCH 1/5] Move sudo steps for platform-with-runcmd to root user to avoid sudo errors on arm build --- .../.devcontainer/Dockerfile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/github-tests/Dockerfile/platform-with-runcmd/.devcontainer/Dockerfile b/github-tests/Dockerfile/platform-with-runcmd/.devcontainer/Dockerfile index e3de188fd..0d1a2fd14 100644 --- a/github-tests/Dockerfile/platform-with-runcmd/.devcontainer/Dockerfile +++ b/github-tests/Dockerfile/platform-with-runcmd/.devcontainer/Dockerfile @@ -10,6 +10,16 @@ ENV DEBIAN_FRONTEND=noninteractive # Set env for tracking that we're running in a devcontainer ENV DEVCONTAINER=true +USER root + +# Configure apt, install packages and general tools +RUN sudo apt-get update \ + && sudo apt-get -y install --no-install-recommends apt-utils dialog nano bash-completion sudo bsdmainutils \ + # + # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed + && sudo apt-get -y install git iproute2 procps lsb-release figlet build-essential + + # This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" # property in devcontainer.json to use it. On Linux, the container user's GID/UIDs # will be updated to match your local UID/GID (when using the dockerFile property). @@ -23,12 +33,6 @@ RUN \ mkdir -p ~/.local/bin \ && echo "export PATH=\$PATH:~/.local/bin" >> ~/.bashrc -# Configure apt, install packages and general tools -RUN sudo apt-get update \ - && sudo apt-get -y install --no-install-recommends apt-utils dialog nano bash-completion sudo bsdmainutils \ - # - # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed - && sudo apt-get -y install git iproute2 procps lsb-release figlet build-essential # Save command line history RUN echo "export HISTFILE=/home/$USERNAME/commandhistory/.bash_history" >> "/home/$USERNAME/.bashrc" \ From 74e9980301c8bec6561e9a020872987adf547694 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Fri, 3 Feb 2023 13:43:09 +0000 Subject: [PATCH 2/5] Update skopeo on platform/runCmd test --- .azure-devops/azure-pipelines.yml | 77 ++++++++++++++++--------------- .github/workflows/ci_common.yml | 6 +++ 2 files changed, 47 insertions(+), 36 deletions(-) diff --git a/.azure-devops/azure-pipelines.yml b/.azure-devops/azure-pipelines.yml index 16aa52efa..77788dfed 100644 --- a/.azure-devops/azure-pipelines.yml +++ b/.azure-devops/azure-pipelines.yml @@ -172,39 +172,44 @@ jobs: inputs: subFolder: github-tests/Dockerfile/build-only - # Temporarily commented out: https://github.com/devcontainers/ci/issues/198 - # - job: test_platform_with_runcmd - # displayName: Test with platform and runCmd - # steps: - # - script: | - # docker login -u $ACR_USERNAME -p $ACR_TOKEN $(ACR_NAME).azurecr.io - # displayName: 'Log in to Azure Container Registry' - # env: - # ACR_NAME: $(ACR_NAME) - # ACR_TOKEN: $(ACR_TOKEN) - # ACR_USERNAME: $(ACR_USERNAME) - - # - script: | - # printenv | sort - # env: - # IMAGE_TAG: $(IMAGE_TAG) - - # - script: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # displayName: Set up QEMU - - # - script: docker buildx create --use - # displayName: Set up docker buildx - - # - task: DevcontainersCi@0 - # inputs: - # imageName: '$(ACR_NAME).azurecr.io/devcontainers-ci/azdo-devcontainer-build-run/test/platform-with-runcmd' - # subFolder: github-tests/Dockerfile/platform-with-runcmd - # platform: linux/amd64,linux/arm64 - # runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]] - - # - script: | - # echo "'runCmdOutput' value: $runCmdOutput" - # if [["$runCmdOutput" = *my-host*]]; then - # echo "'runCmdOutput' output of test_simple job doesn't contain expected value 'my-host'" - # exit 1 - # fi \ No newline at end of file + - job: test_platform_with_runcmd + displayName: Test with platform and runCmd + steps: + - script: | + docker login -u $ACR_USERNAME -p $ACR_TOKEN $(ACR_NAME).azurecr.io + displayName: 'Log in to Azure Container Registry' + env: + ACR_NAME: $(ACR_NAME) + ACR_TOKEN: $(ACR_TOKEN) + ACR_USERNAME: $(ACR_USERNAME) + + - script: | + printenv | sort + env: + IMAGE_TAG: $(IMAGE_TAG) + + - script: | + sudo apt-get update + sudo apt-get -y install skopeo + skopeo --version + displayName: Update skopeo + + - script: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + displayName: Set up QEMU + + - script: docker buildx create --use + displayName: Set up docker buildx + + - task: DevcontainersCi@0 + inputs: + imageName: '$(ACR_NAME).azurecr.io/devcontainers-ci/azdo-devcontainer-build-run/test/platform-with-runcmd' + subFolder: github-tests/Dockerfile/platform-with-runcmd + platform: linux/amd64,linux/arm64 + runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]] + + - script: | + echo "'runCmdOutput' value: $runCmdOutput" + if [["$runCmdOutput" = *my-host*]]; then + echo "'runCmdOutput' output of test_simple job doesn't contain expected value 'my-host'" + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/ci_common.yml b/.github/workflows/ci_common.yml index fa3a570c1..ddc782de1 100644 --- a/.github/workflows/ci_common.yml +++ b/.github/workflows/ci_common.yml @@ -921,6 +921,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Update skopeo + run: | + sudo apt-get update + sudo apt-get -y install skopeo + skopeo --version + - name: Login to GitHub Container Registry uses: docker/login-action@v2 if: ${{ needs.build.outputs.image_push_option == 'filter' }} From aeea4aa593df200d985e931d0e7f2ea07f74f483 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Tue, 7 Feb 2023 16:28:15 +0000 Subject: [PATCH 3/5] Change skopeo update --- .azure-devops/azure-pipelines.yml | 11 +++++++++-- .github/workflows/ci_common.yml | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.azure-devops/azure-pipelines.yml b/.azure-devops/azure-pipelines.yml index 77788dfed..368f9f6a0 100644 --- a/.azure-devops/azure-pipelines.yml +++ b/.azure-devops/azure-pipelines.yml @@ -189,11 +189,18 @@ jobs: IMAGE_TAG: $(IMAGE_TAG) - script: | + sudo apt purge buildah golang-github-containers-common podman skopeo + sudo apt autoremove --purge + REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable" + source /etc/os-release + sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list" + sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key + sudo apt-key add Release.key sudo apt-get update - sudo apt-get -y install skopeo - skopeo --version + sudo apt-get install skopeo displayName: Update skopeo + - script: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes displayName: Set up QEMU diff --git a/.github/workflows/ci_common.yml b/.github/workflows/ci_common.yml index ddc782de1..bab6b1917 100644 --- a/.github/workflows/ci_common.yml +++ b/.github/workflows/ci_common.yml @@ -921,11 +921,19 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + # This can be omitted once runner images have a version of Skopeo > 1.4.1 + # See https://github.com/containers/skopeo/issues/1874 (and https://github.com/devcontainers/ci/issues/191#issuecomment-1416384710) - name: Update skopeo run: | + sudo apt purge buildah golang-github-containers-common podman skopeo + sudo apt autoremove --purge + REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable" + source /etc/os-release + sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list" + sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key + sudo apt-key add Release.key sudo apt-get update - sudo apt-get -y install skopeo - skopeo --version + sudo apt-get install skopeo - name: Login to GitHub Container Registry uses: docker/login-action@v2 From 756f32eb4e3410b32c8cf300b549d0abe8ae9dc4 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Tue, 28 Feb 2023 15:28:29 +0000 Subject: [PATCH 4/5] test push in GH action --- .github/workflows/ci_common.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci_common.yml b/.github/workflows/ci_common.yml index bab6b1917..bd074c309 100644 --- a/.github/workflows/ci_common.yml +++ b/.github/workflows/ci_common.yml @@ -960,8 +960,7 @@ jobs: imageName: ghcr.io/devcontainers/ci/tests/platform-with-runcmd platform: linux/amd64,linux/arm64 runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]] - push: never # Temporarily suppress push: https://github.com/devcontainers/ci/issues/198 - # push: ${{ needs.build.outputs.image_push_option }} + push: always ## TODO - revert once tested: ${{ needs.build.outputs.image_push_option }} eventFilterForPush: | push pull_request From 53eb99020f0768095d5b8a17f20acc441869fbd5 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Tue, 28 Feb 2023 15:46:15 +0000 Subject: [PATCH 5/5] rest test push option --- .github/workflows/ci_common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_common.yml b/.github/workflows/ci_common.yml index bd074c309..d860e9252 100644 --- a/.github/workflows/ci_common.yml +++ b/.github/workflows/ci_common.yml @@ -960,7 +960,7 @@ jobs: imageName: ghcr.io/devcontainers/ci/tests/platform-with-runcmd platform: linux/amd64,linux/arm64 runCmd: echo $HOSTNAME && [[ $HOSTNAME == "my-host" ]] - push: always ## TODO - revert once tested: ${{ needs.build.outputs.image_push_option }} + push: ${{ needs.build.outputs.image_push_option }} eventFilterForPush: | push pull_request