Skip to content

Commit c6f39bc

Browse files
bgauduchbgauduch
andauthored
🔧 Workflow rework (#108)
* ⚗️ testing matrix load from JSON * ⬆️ update dockerfile dependencies * 🔧 use latest hadolint tag for local lint * ⚗️ correct multi-line JSON parsing * extract lint to dedicated workflow, add multi-build for branches * correct build-test workflow * correct build-test workflow * ⚗️ add test config generation in build-test workflow * correct envsubst command * update badges in ireadme, renamed lint action * 👌 review by @pyaillet and @gmembre-zenika * upgrade default and supported versions * pin hadolint version in linit acion * small readme corrections, add a dependencies upgrade cheklist * correct az cli installation and update default tetst config Co-authored-by: bgauduch <user.personal@users.noreply.github.com>
1 parent 42c4e2a commit c6f39bc

11 files changed

+247
-139
lines changed

.github/workflows/build-test.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: build-test
2+
3+
# trigger on any push
4+
# but not on master, tags or markdown modifications
5+
on:
6+
push:
7+
tags-ignore:
8+
- "**"
9+
branches:
10+
- "**"
11+
- "!master"
12+
paths-ignore:
13+
- "!README.md"
14+
- "!CODE_OF_CONDUCT.md"
15+
16+
env:
17+
IMAGE_NAME: "terraform-azure-cli"
18+
19+
jobs:
20+
load_supported_versions:
21+
runs-on: ubuntu-20.04
22+
23+
outputs:
24+
matrix: ${{ steps.set-matrix.outputs.matrix }}
25+
26+
steps:
27+
- name: Check out the repo
28+
uses: actions/checkout@v2
29+
30+
- name: Save supported versions as output
31+
id: set-matrix
32+
run: |
33+
SUPPORTED_VERSIONS=$(cat ./supported_versions.json)
34+
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//'%'/%25}"
35+
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\n'/%0A}"
36+
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\r'/%0D}"
37+
echo "::set-output name=matrix::${SUPPORTED_VERSIONS}"
38+
39+
build:
40+
runs-on: ubuntu-20.04
41+
needs: load_supported_versions
42+
strategy:
43+
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }}
44+
45+
steps:
46+
- name: Check out the repo
47+
uses: actions/checkout@v2
48+
49+
- name: Save branch name as env var
50+
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
51+
52+
- name: Build and save image tag
53+
run: echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV
54+
55+
- name: Build image
56+
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}
57+
58+
- name: Save image
59+
run: docker image save --output ${IMAGE_NAME}_${IMAGE_TAG}.tar ${IMAGE_NAME}:${IMAGE_TAG}
60+
61+
- name: Upload image artifact
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}
65+
path: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}.tar
66+
67+
test:
68+
runs-on: ubuntu-20.04
69+
needs:
70+
- build
71+
- load_supported_versions
72+
strategy:
73+
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }}
74+
75+
steps:
76+
- name: Checkout source
77+
uses: actions/checkout@v2
78+
79+
- name: Save branch name as env var
80+
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
81+
82+
- name: Build and save image tag
83+
run: echo "IMAGE_TAG=${BRANCH}_terraform-${{ matrix.tf_version }}_azcli-${{ matrix.azcli_version }}" >> $GITHUB_ENV
84+
85+
- name: Download image artifact
86+
uses: actions/download-artifact@v2
87+
with:
88+
name: ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}
89+
90+
- name: Load image
91+
run: docker image load --input ${{ env.IMAGE_NAME }}_${{ env.IMAGE_TAG }}.tar
92+
93+
- name: Generate test config
94+
run: |
95+
export TF_VERSION=${{ matrix.tf_version }}
96+
export AZ_VERSION=${{ matrix.azcli_version }}
97+
envsubst '${TF_VERSION},${AZ_VERSION}' < tests/container-structure-tests.yml.template > tests/container-structure-tests.yml
98+
99+
- name: run structure tests
100+
uses: plexsystems/container-structure-test-action@v0.2.0
101+
with:
102+
image: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
103+
config: tests/container-structure-tests.yml

.github/workflows/lint-build-test.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

.github/workflows/lint-dockerfile.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: lint-dockerfile
2+
3+
# trigger on any Dockerfile modification
4+
on:
5+
push:
6+
paths:
7+
- "Dockerfile"
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-20.04
12+
13+
steps:
14+
- name: Check out the repo
15+
uses: actions/checkout@v2
16+
17+
- name: Lint Dockerfile
18+
uses: brpaz/hadolint-action@v1.3.1
19+
with:
20+
dockerfile: "Dockerfile"

.github/workflows/push-latest.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,16 @@ on:
77
- "master"
88
paths-ignore:
99
- "!README.md"
10+
- "!CODE_OF_CONDUCT.md"
1011

1112
env:
1213
ORGANIZATION: "zenika"
1314
IMAGE_NAME: "terraform-azure-cli"
1415
IMAGE_TAG: "latest"
1516

1617
jobs:
17-
lint:
18-
runs-on: ubuntu-latest
19-
20-
steps:
21-
- name: Check out the repo
22-
uses: actions/checkout@v2
23-
24-
- name: Lint Dockerfile
25-
uses: brpaz/hadolint-action@master
26-
with:
27-
dockerfile: "Dockerfile"
28-
2918
build_push_latest:
30-
runs-on: ubuntu-latest
31-
needs: lint
19+
runs-on: ubuntu-20.04
3220

3321
steps:
3422
- name: Check out the repo

.github/workflows/release.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,32 @@ on:
66
types: [published]
77

88
jobs:
9-
lint:
10-
runs-on: ubuntu-latest
9+
load_supported_versions:
10+
runs-on: ubuntu-20.04
11+
12+
outputs:
13+
matrix: ${{ steps.set-matrix.outputs.matrix }}
1114

1215
steps:
1316
- name: Check out the repo
1417
uses: actions/checkout@v2
1518

16-
- name: Lint Dockerfile
17-
uses: brpaz/hadolint-action@master
18-
with:
19-
dockerfile: "Dockerfile"
19+
- name: Save supported versions as output
20+
id: set-matrix
21+
run: |
22+
SUPPORTED_VERSIONS=$(cat ./supported_versions.json)
23+
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//'%'/%25}"
24+
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\n'/%0A}"
25+
SUPPORTED_VERSIONS="${SUPPORTED_VERSIONS//$'\r'/%0D}"
26+
echo "::set-output name=matrix::${SUPPORTED_VERSIONS}"
2027
2128
build_push_release:
22-
runs-on: ubuntu-latest
23-
needs: lint
29+
runs-on: ubuntu-20.04
30+
needs:
31+
- load_supported_versions
2432

2533
strategy:
26-
matrix:
27-
tf_version:
28-
- "0.11.14"
29-
- "0.12.29"
30-
- "0.13.5"
31-
- "0.14.0"
32-
33-
azcli_version:
34-
- "2.13.0"
35-
- "2.14.2"
36-
- "2.15.1"
34+
matrix: ${{ fromJSON(needs.load_supported_versions.outputs.matrix) }}
3735

3836
env:
3937
ORGANIZATION: "zenika"

Dockerfile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Setup build arguments with default versions
2-
ARG AZURE_CLI_VERSION=2.15.1
3-
ARG TERRAFORM_VERSION=0.14.0
2+
ARG AZURE_CLI_VERSION=2.20.0
3+
ARG TERRAFORM_VERSION=0.14.8
44
ARG PYTHON_MAJOR_VERSION=3.7
5-
ARG DEBIAN_VERSION=buster-20201012-slim
5+
ARG DEBIAN_VERSION=buster-20210208-slim
66

77
# Download Terraform binary
88
FROM debian:${DEBIAN_VERSION} as terraform-cli
99
ARG TERRAFORM_VERSION
1010
RUN apt-get update
11+
RUN apt-get install -y --no-install-recommends apt-utils=1.8.2.2
1112
RUN apt-get install -y --no-install-recommends curl=7.64.0-4+deb10u1
12-
RUN apt-get install -y --no-install-recommends ca-certificates=20190110
13-
RUN apt-get install -y --no-install-recommends unzip=6.0-23+deb10u1
13+
RUN apt-get install -y --no-install-recommends ca-certificates=20200601~deb10u2
14+
RUN apt-get install -y --no-install-recommends unzip=6.0-23+deb10u2
1415
RUN apt-get install -y --no-install-recommends gnupg=2.2.12-1+deb10u1
1516
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS
1617
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
@@ -27,21 +28,23 @@ FROM debian:${DEBIAN_VERSION} as azure-cli
2728
ARG AZURE_CLI_VERSION
2829
ARG PYTHON_MAJOR_VERSION
2930
RUN apt-get update
31+
RUN apt-get install -y --no-install-recommends apt-utils=1.8.2.2
3032
RUN apt-get install -y --no-install-recommends python3=${PYTHON_MAJOR_VERSION}.3-1
3133
RUN apt-get install -y --no-install-recommends python3-pip=18.1-5
3234
RUN apt-get install -y --no-install-recommends gcc=4:8.3.0-1
3335
RUN apt-get install -y --no-install-recommends python3-dev=${PYTHON_MAJOR_VERSION}.3-1
34-
RUN pip3 install setuptools==50.3.2
35-
RUN pip3 install wheel==0.35.1
36-
RUN pip3 install azure-cli==${AZURE_CLI_VERSION}
36+
RUN pip3 install --upgrade --no-cache-dir pip==21.0.1
37+
RUN pip3 install --no-cache-dir setuptools==54.1.1
38+
RUN pip3 install --no-cache-dir wheel==0.36.2
39+
RUN pip3 install --no-cache-dir azure-cli==${AZURE_CLI_VERSION}
3740

3841
# Build final image
3942
FROM debian:${DEBIAN_VERSION}
4043
LABEL maintainer="bgauduch@github"
4144
ARG PYTHON_MAJOR_VERSION
4245
RUN apt-get update \
4346
&& apt-get install -y --no-install-recommends \
44-
ca-certificates=20190110 \
47+
ca-certificates=20200601~deb10u2 \
4548
git=1:2.20.1-2+deb10u3 \
4649
python3=${PYTHON_MAJOR_VERSION}.3-1 \
4750
python3-distutils=${PYTHON_MAJOR_VERSION}.3-1 \

0 commit comments

Comments
 (0)