diff options
author | Joris Roovers <joris.roovers@gmail.com> | 2023-03-21 13:50:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-21 13:50:34 +0100 |
commit | daa057c883445d8d3fe2c9a6ca9c08967c7c91dc (patch) | |
tree | e2776243a9aec0c203469110ddc6a275015626e0 | |
parent | dfa4af306b203c753194c97ab55a14f946b42855 (diff) |
GHA: Docker Test workflow improvements (#475)
- Fixes and tweaks for the test-docker workflow
- Adds extra docker_image_tag parameter to publish-release workflow. Before
this was hardcoded to "latest_dev" which didn't work for publishing an
non-pre release.
- Triggers the test-docker workflow at the end of the publish-docker workflow
to do a quick smoke test on newly published docker images
-rw-r--r-- | .github/workflows/ci.yml | 1 | ||||
-rw-r--r-- | .github/workflows/github-release.yml | 1 | ||||
-rw-r--r-- | .github/workflows/publish-docker.yml | 21 | ||||
-rw-r--r-- | .github/workflows/publish-release.yml | 16 | ||||
-rw-r--r-- | .github/workflows/test-docker.yml | 35 |
5 files changed, 53 insertions, 21 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 403dcc4..013fbc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,3 +140,4 @@ jobs: with: pypi_target: "pypi.org" repo_release_ref: "main" + docker_image_tag: "latest_dev" diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index e5e40c9..76f5303 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -12,3 +12,4 @@ jobs: with: pypi_target: "pypi.org" repo_release_ref: ${{ github.ref_name }} + docker_image_tag: "Use $gitlint_version" diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 092b6b3..64bf24b 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -1,5 +1,5 @@ name: Publish Docker -run-name: "Publish Docker (gitlint_version=${{ inputs.gitlint_version }})" +run-name: "Publish Docker (gitlint_version=${{ inputs.gitlint_version }}, docker_image_tag=${{ inputs.docker_image_tag }})" on: workflow_call: @@ -38,8 +38,10 @@ on: default: false jobs: - publish_docker: + publish-docker: runs-on: "ubuntu-latest" + outputs: + docker_image_tag: ${{ steps.set_tag.outputs.docker_image_tag }} steps: - name: Determine docker tag id: set_tag @@ -62,12 +64,12 @@ jobs: build-args: GITLINT_VERSION=${{ inputs.gitlint_version }} tags: jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} - - name: Test docker image + - name: Test docker image (local) run: | gitlint_version=$(docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} --version) + echo "$gitlint_version == 'gitlint, version ${{ inputs.gitlint_version }}'" [ "$gitlint_version" == "gitlint, version ${{ inputs.gitlint_version }}" ] - # This won't actually rebuild the docker image, but just push the previously built and cached image - name: Push docker image uses: docker/build-push-action@v4 @@ -76,4 +78,13 @@ jobs: build-args: GITLINT_VERSION=${{ inputs.gitlint_version }} tags: jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} if: inputs.push_to_dockerhub -
\ No newline at end of file + + # Retest docker image after publishing + test-docker: + needs: + - publish-docker + uses: ./.github/workflows/test-docker.yml + with: + docker_image_tag: ${{ needs.publish-docker.outputs.docker_image_tag }} + gitlint_version: ${{ inputs.gitlint_version }} + if: inputs.push_to_dockerhub
\ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 22ac4be..5234efb 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -14,6 +14,11 @@ on: description: "Gitlint git reference to publish release for" type: string default: "main" + docker_image_tag: + description: "Docker image tag" + required: true + type: string + default: "latest_dev" # Manually trigger a release workflow_dispatch: @@ -30,6 +35,15 @@ on: description: "Gitlint git reference to publish release for" type: string default: "main" + docker_image_tag: + description: "Docker image tag" + required: true + type: choice + options: + - "latest_dev" + - "latest" + - "Use $gitlint_version" + default: "latest_dev" jobs: publish: @@ -172,5 +186,5 @@ jobs: secrets: inherit # pass all secrets (required to access secrets in a called workflow) with: gitlint_version: ${{ needs.publish.outputs.gitlint_version }} - docker_image_tag: "latest_dev" + docker_image_tag: ${{ inputs.docker_image_tag }} push_to_dockerhub: true diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index 073c2f2..b811c41 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -1,26 +1,30 @@ name: Test Docker -run-name: "Test Docker (docker_tag=${{ inputs.docker_tag }}, gitlint_version=${{ inputs.gitlint_version }})" +run-name: "Test Docker (docker_image_tag=${{ inputs.docker_image_tag }}, gitlint_version=${{ inputs.gitlint_version }})" on: workflow_call: inputs: - docker_tag: + docker_image_tag: description: "Docker tag to pull and run (latest, latest_dev, 0.15.0, etc)" required: true + type: string default: "latest" gitlint_version: description: "Expected gitlint version (0.15.0, etc)" required: true + type: string default: "0.15.0" workflow_dispatch: inputs: - docker_tag: + docker_image_tag: description: "Docker tag to pull and run (latest, latest_dev, 0.15.0, etc)" required: true + type: string default: "latest" gitlint_version: description: "Expected gitlint version (0.15.0, etc)" required: true + type: string default: "0.15.0" jobs: @@ -28,19 +32,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Run gitlint --version using docker + - name: Pull gitlint docker image (jorisroovers/gitlint:${{ inputs.docker_image_tag }}) run: | - DOCKER_TAG=${{ github.event.inputs.docker_tag }} - GITLINT_VERSION=${{ github.event.inputs.gitlint_version }} - - GITLINT_CURRENT_VERSION=$(docker run --rm -v $(pwd):/repo jorisroovers/gitlint:${DOCKER_TAG} --version) - echo "gitlint version: ${GITLINT_CURRENT_VERSION}" - - if [[ ! "${GITLINT_CURRENT_VERSION}" =~ "${GITLINT_VERSION}" ]]; then - echo "Error: Expected version ${GITLINT_VERSION} != ${GITLINT_CURRENT_VERSION}" - exit 1 - fi + docker pull jorisroovers/gitlint:${{ inputs.docker_image_tag }} + + - name: Run gitlint --debug + run: | + docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint:${{ inputs.docker_image_tag }} --debug --msg-filename /repo/gitlint-core/gitlint/tests/samples/commit_message/no-violations + + - name: Run gitlint --version + run: | + gitlint_version=$(docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint:${{ inputs.docker_image_tag }} --version) + echo "$gitlint_version == 'gitlint, version ${{ inputs.gitlint_version }}'" + [ "$gitlint_version" == "gitlint, version ${{ inputs.gitlint_version }}" ]
\ No newline at end of file |