Skip to content

Bump actions/checkout from 4.1.7 to 4.2.1 #652

Bump actions/checkout from 4.1.7 to 4.2.1

Bump actions/checkout from 4.1.7 to 4.2.1 #652

Workflow file for this run

name: test
on: [push]
env:
TAG_PREFIX: artifactory.hashicorp.engineering/actions-docker-build/test
jobs:
bats-tests:
runs-on: ubuntu-latest
steps:
- name: Install BATS
env:
BATS_VERSION: 1.5.0
BATS_REPO: https://github.com/bats-core/bats-core
BATS_PATH: /usr/local/bats
run: |
sudo git clone --depth 1 --branch "v$BATS_VERSION" "$BATS_REPO" "$BATS_PATH"
echo "$BATS_PATH/bin" >> "$GITHUB_PATH"
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Run BATS tests
run: make test
# The action we're testing expects to download an artifact,
# so here we upload it in preperation.
action-test-prep:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Zip Test Bin
run: |
zip ./testdata/test_bin.zip ./testdata/test_bin
zip ./testdata/actions-docker-build.zip ./testdata/actions-docker-build
- name: Upload a test artifact.
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
path: testdata/test_bin.zip
name: test_bin.zip
- name: Upload a test artifact.
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
path: testdata/actions-docker-build.zip
name: actions-docker-build.zip
action-test-dockerfile-in-root:
runs-on: ubuntu-latest
env:
OVERRIDE_TARBALL_NAME: action-test-dockerfile-in-root.docker.tar
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
# Test setup.
- name: Move Dockerfile to Repo Root
run: |
mv testdata/Dockerfile ./
ls -lah
- name: Invoke Action
uses: ./ # This is the action we're testing.
with:
version: 1.0.0
target: default
arch: amd64
tags: |
${{env.TAG_PREFIX}}/action-test-dockerfile-in-root:tag1
${{env.TAG_PREFIX}}/action-test-dockerfile-in-root:tag2
zip_artifact_name: test_bin.zip
bin_name: test_bin
# No overrides to Dockerfile path.
- name: Assert Tarball Created And Contains Correct Tags
run: |
source scripts/assertions.bash
REPO="${{env.TAG_PREFIX}}/action-test-dockerfile-in-root"
assert_tarball_contains_tags "$OVERRIDE_TARBALL_NAME" "$REPO:tag1" "$REPO:tag2"
action-test-setting-dockerfile:
runs-on: ubuntu-latest
env:
OVERRIDE_TARBALL_NAME: action-test-setting-dockerfile.docker.tar
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Invoke Action
uses: ./ # This is the action we're testing.
with:
version: 1.0.0
target: default
arch: amd64
tags: |
${{env.TAG_PREFIX}}/action-test-setting-dockerfile:tag1
${{env.TAG_PREFIX}}/action-test-setting-dockerfile:tag2
zip_artifact_name: test_bin.zip
bin_name: test_bin
# Test setting just dockerfile.
dockerfile: testdata/Dockerfile
- name: Assert Tarball Created And Contains Correct Tags
run: |
source scripts/assertions.bash
REPO="${{env.TAG_PREFIX}}/action-test-setting-dockerfile"
assert_tarball_contains_tags "$OVERRIDE_TARBALL_NAME" "$REPO:tag1" "$REPO:tag2"
action-test-setting-workdir:
runs-on: ubuntu-latest
env:
OVERRIDE_TARBALL_NAME: action-test-setting-workdir.docker.tar
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Invoke Action
uses: ./ # This is the action we're testing.
with:
version: 1.0.0
target: default
arch: amd64
tags: |
${{env.TAG_PREFIX}}/action-test-setting-workdir:tag1
${{env.TAG_PREFIX}}/action-test-setting-workdir:tag2
zip_artifact_name: test_bin.zip
bin_name: test_bin
# Test setting just workdir.
workdir: testdata
- name: Assert Tarball Created And Contains Correct Tags
run: |
source scripts/assertions.bash
REPO="${{env.TAG_PREFIX}}/action-test-setting-workdir"
assert_tarball_contains_tags "$OVERRIDE_TARBALL_NAME" "$REPO:tag1" "$REPO:tag2"
action-test-smoke-test-pass:
runs-on: ubuntu-latest
env:
OVERRIDE_TARBALL_NAME: action-test-smoke-test-pass.docker.tar
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Invoke Action
uses: ./
with:
version: 1.0.0
target: default
arch: amd64
tags: |
${{env.TAG_PREFIX}}/action-test-smoke-test-pass:tag1
${{env.TAG_PREFIX}}/action-test-smoke-test-pass:tag2
zip_artifact_name: test_bin.zip
bin_name: test_bin
dockerfile: testdata/Dockerfile
#test smoke test. This should pass
smoke_test: |
docker run "${IMAGE_NAME}" /bin/"${BIN_NAME}"
action-test-smoke-test-fail:
runs-on: ubuntu-latest
env:
OVERRIDE_TARBALL_NAME: action-test-smoke-test-fail.docker.tar
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Invoke Action
id: docker-build
uses: ./
with:
version: 1.0.0
target: default
arch: amd64
tags: |
${{env.TAG_PREFIX}}/action-test-smoke-test-fail:tag1
${{env.TAG_PREFIX}}/action-test-smoke-test-fail:tag2
zip_artifact_name: test_bin.zip
bin_name: test_bin
dockerfile: testdata/Dockerfile
# Test smoke test failure
smoke_test: |
exit 1
continue-on-error: true
- name: Check smoke test fail
env:
TEST_RESULT: ${{ steps.docker-build.outcome }}
run: |
if [ "${TEST_RESULT}" == 'success' ]; then
exit 1
echo "Successfully failed smoke test."
fi
action-test-redhat-tag-only:
runs-on: ubuntu-latest
env:
OVERRIDE_REDHAT_TARBALL_NAME: action-test-redhat-tag-only.docker.tar
TEST_REDHAT_TAG: quay.io/redhat-isv-containers/63111fb3496edcd88344ab5b:1.2.3
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
# Test setup.
- name: Move Dockerfile to Repo Root
run: |
mv testdata/Dockerfile ./
ls -lah
- name: Invoke Action
uses: ./ # This is the action we're testing.
with:
version: 1.0.0
target: default
arch: amd64
redhat_tag: ${{env.TEST_REDHAT_TAG}}
zip_artifact_name: test_bin.zip
bin_name: test_bin
- name: Assert Tarball Created And Contains Correct Tags
run: |
source scripts/assertions.bash
assert_tarball_contains_tags "$OVERRIDE_REDHAT_TARBALL_NAME" "$TEST_REDHAT_TAG"
action-test-guessed-bin-name:
runs-on: ubuntu-latest
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
# Test setup
- name: Move Dockerfile to Repo Root
run: |
mv testdata/Dockerfile ./
- name: Invoke Action
uses: ./
with:
version: 1.0.0
target: default
arch: amd64
zip_artifact_name: actions-docker-build.zip
#bin_name: actions-docker-build # (which matches the $reponame)
tags: ${{env.TAG_PREFIX}}/action-test-dockerfile-in-root:tag1
action-test-opt-out-extract:
runs-on: ubuntu-latest
needs:
- action-test-prep
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
# Handle the artifact download ourselves
- name: Download Product Zip Artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: archive
name: actions-docker-build.zip
# Construct the custom context,
# This is "required" because normally our extraction process puts the artifacts in deeply nested
# `dist/$TARGETOS/$TARGETARCH/$BIN_NAME` paths.
# As the caller, I don't even want to guess what that should be.
- name: Custom context
run: |
mkdir -p my-context-dir
cp -v testdata/opt-out.Dockerfile ./my-context-dir/Dockerfile
unzip -j archive/actions-docker-build.zip -d ./my-context-dir
- name: Invoke Action
uses: ./
with:
version: 1.0.0
target: default
arch: arm64
do_zip_extract_step: false
workdir: ./my-context-dir
tags: ${{env.TAG_PREFIX}}/action-test-dockerfile-in-root:tag1