Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Dockerfile to resolve build issues due to vintage #131

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 11 additions & 59 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name: build-test
# but not on master or tags
# and only for Dockerfile related modifications
on:
workflow_dispatch:
push:
tags-ignore:
- "**"
Expand All @@ -22,30 +23,14 @@ env:
IMAGE_NAME: "terraform-azure-cli"

jobs:
load_supported_versions:
runs-on: ubuntu-20.04

outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Save supported versions as output
id: set-matrix
run: |
SUPPORTED_VERSIONS=$(cat ./supported_versions.json)
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//'%'/%25}"
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\n'/%0A}"
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\r'/%0D}"
echo "::set-output name=matrix::${SUPPORTED_VERSIONS}"
load_versions:
uses: ./.github/workflows/include_supported-versions.yml
Comment on lines +26 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using reusables workflow is a very nice addition, much more DRY this way !

If possible, it might be a good idea to shrink their names and store them in a subdirectories, for instance .github/workflows/reusables/latest-version.yml. What do you think ?


build:
build_containers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this job build container images, it would be renamed:

Suggested change
build_containers:
build_test_containers_images:

runs-on: ubuntu-20.04
needs: load_supported_versions
needs: load_versions
strategy:
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }}
matrix: ${{ fromJSON(needs.load_versions.outputs.matrix) }}

steps:
- name: Check out the repo
Expand All @@ -55,54 +40,21 @@ jobs:
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Build and save image tag
run: echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV

run: |
echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV
echo $IMAGE_TAG

- name: Build image
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ matrix.tf_version }} --build-arg AZURE_CLI_VERSION=${{ matrix.azcli_version }} --tag ${IMAGE_NAME}:${IMAGE_TAG}

- name: Save image
run: docker image save --output ${IMAGE_NAME}_${IMAGE_TAG}.tar ${IMAGE_NAME}:${IMAGE_TAG}

- name: Upload image artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}
path: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}.tar

test:
runs-on: ubuntu-20.04
needs:
- build
- load_supported_versions
strategy:
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }}

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Save branch name as env var
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Build and save image tag
run: echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV

- name: Download image artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}

- name: Load image
run: docker image load --input ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}.tar

- name: Generate test config
run: |
export TF_VERSION=${{ matrix.tf_version }}
export AZ_VERSION=${{ matrix.azcli_version }}
envsubst '${TF_VERSION},${AZ_VERSION}' < tests/container-structure-tests.yml.template > tests/container-structure-tests.yml

- name: run structure tests
uses: plexsystems/container-structure-test-action@v0.2.0
uses: plexsystems/container-structure-test-action@v0.3.0
with:
image: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
config: tests/container-structure-tests.yml
2 changes: 1 addition & 1 deletion .github/workflows/dockerhub-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASS }}
repository: zenika/terraform-azure-cli
repository: ${{ secrets.DOCKERHUB_USERNAME }}/terraform-azure-cli
43 changes: 43 additions & 0 deletions .github/workflows/include_latest-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Load Supported Versions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Load Supported Versions
name: Load Latest Supported Versions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you stated in the name, it might be better to keep the file name plural as latest version is exposed for multi tools, what do you think ?

That would be: .github/workflows/include_latest-versions.yml


on:
workflow_call:
outputs:
azcli_version:
description: "Latest supported azcli version"
value: ${{ jobs.load_versions.outputs.azcli_version }}
tf_version:
description: "Latest supported terraform version"
value: ${{ jobs.load_versions.outputs.tf_version }}
workflow_dispatch:

jobs:
load_versions:
runs-on: ubuntu-20.04
outputs:
azcli_version: ${{ env.azcli_version }}
tf_version: ${{ env.tf_version }}

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Save supported versions as output
id: set-matrix
run: |
echo "azcli_version=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV
echo "tf_version=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV

- name: output
run: |
echo $azcli_version
echo $tf_version

display_versions:
needs: load_versions
runs-on: ubuntu-latest
steps:
- name: Access Variable
run: |
echo "azcli_version=${{ needs.load_versions.outputs.azcli_version }}"
echo "tf_version=${{ needs.load_versions.outputs.tf_version }}"
50 changes: 50 additions & 0 deletions .github/workflows/include_supported-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Load Supported Versions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I didn't understand correctly, but aren't include_latest-version and include_supported-versions.yml a bit of a duplication ?

The only difference I can sport is sort | reverse VS sort | .[-1] for both TF and AWSCLI versions, I'm not sure to quite understand the use case.

EDIT :
Oh okay the difference is the latest version for each VS a matrix of all versions for each tool.

In that cas, a plural on outputs would be nice 😉


on:
workflow_call:
outputs:
matrix:
description: "Matrix of supported versions"
value: ${{ jobs.load_versions.outputs.matrix }}
azcli_version:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
azcli_version:
azcli_versions:

Beware of references elsewhere in the code

description: "Matrix of supported azcli versions"
value: ${{ jobs.load_versions.outputs.azcli_version }}
tf_version:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tf_version:
tf_versions:

Beware of references elsewhere in the code

description: "Matrix of supported terraform versions"
value: ${{ jobs.load_versions.outputs.tf_version }}
workflow_dispatch:

jobs:
load_versions:
runs-on: ubuntu-20.04
outputs:
azcli_version: ${{ env.azcli_version }}
tf_version: ${{ env.tf_version }}
matrix: ${{ env.matrix }}

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Save supported versions as output
id: set-matrix
run: |
echo "azcli_version=$(jq -r -c '.azcli_version | sort | reverse' supported_versions.json)" >> $GITHUB_ENV
echo "tf_version=$(jq -r -c '.tf_version | sort | reverse' supported_versions.json)" >> $GITHUB_ENV
echo -e matrix=\{"azcli_version": $(jq -r -c '.azcli_version | sort | reverse' supported_versions.json), "tf_version": $(jq -r -c '.tf_version | sort | reverse' supported_versions.json)\} >> $GITHUB_ENV

- name: output
run: |
echo $azcli_version
echo $tf_version
echo $matrix

display_versions:
needs: load_versions
runs-on: ubuntu-latest
steps:
- name: Access Variable
run: |
echo "azcli_version=${{ needs.load_versions.outputs.azcli_version }}"
echo "tf_version=${{ needs.load_versions.outputs.tf_version }}"
echo "matrix=${{ needs.load_versions.outputs.matrix }}"
18 changes: 8 additions & 10 deletions .github/workflows/push-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,35 @@ on:
- ".github/workflows/push-latest.yml"

env:
ORGANIZATION: "zenika"
IMAGE_NAME: "terraform-azure-cli"
IMAGE_TAG: "latest"

jobs:
latest_version:
uses: ./.github/workflows/include_latest-version.yml

build_push_latest:
runs-on: ubuntu-20.04
needs: latest_version

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Retrieve latest suported versions
run: |
echo "AZ_VERSION=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV
echo "TF_VERSION=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV

- name: Build image
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${TF_VERSION} --build-arg AZURE_CLI_VERSION=${AZ_VERSION} --tag $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ needs.latest_version.outputs.tf_version }} --build-arg AZURE_CLI_VERSION=${{ needs.latest_version.outputs.azcli_version }} --tag ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$IMAGE_TAG

- name: Login to Docker Hub registry
run: echo '${{ secrets.DOCKERHUB_PASS }}' | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Push image to registry
run: docker push $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$IMAGE_TAG

- name: Save image
run: docker image save -o $IMAGE_NAME-$IMAGE_TAG.tar $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
run: docker image save -o $IMAGE_NAME-$IMAGE_TAG.tar ${{ secrets.DOCKERHUB_USERNAME }}/$IMAGE_NAME:$IMAGE_TAG
Comment on lines -42 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dockerhub_username secret might not alway be "Zenika" and is not intended to identify the container registry name, so I would suggest to keep the ORGANISATION env as it were


- name: Upload image artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}
path: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}.tar
35 changes: 10 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,18 @@ on:
types: [published]

jobs:
load_supported_versions:
runs-on: ubuntu-20.04

outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Save supported versions as output
id: set-matrix
run: |
SUPPORTED_VERSIONS=$(cat ./supported_versions.json)
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//'%'/%25}"
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\n'/%0A}"
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\r'/%0D}"
echo "::set-output name=matrix::${SUPPORTED_VERSIONS}"
load_versions:
uses: ./.github/workflows/include_supported-versions.yml

build_push_release:
runs-on: ubuntu-20.04
needs:
- load_supported_versions
- load_versions

strategy:
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }}
matrix: ${{ fromJSON(needs.load_versions.outputs.matrix) }}

env:
ORGANIZATION: "zenika"
IMAGE_NAME: "terraform-azure-cli"

steps:
Expand All @@ -48,19 +31,21 @@ jobs:
run: echo "IMAGE_RELEASE_TAG=release-${RELEASE_TAG}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV

- name: Build image
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ matrix.tf_version }} --build-arg AZURE_CLI_VERSION=${{ matrix.azcli_version }} --tag ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${{ matrix.tf_version }} --build-arg AZURE_CLI_VERSION=${{ matrix.azcli_version }} --tag ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}
Comment on lines -51 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feedback as in push-latest workflow, we might be better off keeping ORGANIZATION env var


- name: Login to Docker Hub registry
run: echo '${{ secrets.DOCKERHUB_PASS }}' | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Push image to registry
run: docker push ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}
run: |
docker images
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}

- name: Save image
run: docker image save -o ${IMAGE_NAME}-${IMAGE_RELEASE_TAG}.tar ${ORGANIZATION}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}
run: docker image save -o ${IMAGE_NAME}-${IMAGE_RELEASE_TAG}.tar ${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}:${IMAGE_RELEASE_TAG}

- name: Upload image artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_RELEASE_TAG }}
path: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_RELEASE_TAG }}.tar
29 changes: 29 additions & 0 deletions .github/workflows/test-harness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: test_supported-versions.yaml
on:
push:
jobs:
load_versions:
uses: ./.github/workflows/include_supported-versions.yml

latest_version:
uses: ./.github/workflows/include_latest-version.yml

check_values:
runs-on: ubuntu-latest
needs: load_versions
strategy:
matrix: ${{ fromJSON(needs.load_versions.outputs.matrix) }}
steps:
- name: Test access to values
run: |
echo ${{ needs.load_versions.outputs.matrix }}
echo tf_${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}

check_latest:
runs-on: ubuntu-latest
needs: latest_version
steps:
- name: Test access to values
run: |
echo terraform: ${{ needs.latest_version.outputs.tf_version }}
echo azcli: ${{ needs.latest_version.outputs.azcli_version }}
Loading