Skip to content

Commit 5a482aa

Browse files
authored
Add container structure test (#76)
* 🐳 add maintainer label to Dockerfile * ✅ add container structure test config * 👷 add container structure test to build-test workflow * 📝 udpated dev-build doc and moved to script folder * 💚 add missing JSON schema version in test config * 💚 correct test file * 👷 ignoring reamde modification for push-latest workflow trigger * 👷 trigger realease workflow on published realeases instead of tags
1 parent aa308da commit 5a482aa

File tree

7 files changed

+55
-10
lines changed

7 files changed

+55
-10
lines changed

.github/workflows/build.yml renamed to .github/workflows/build-test.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
name: build
1+
name: build-test
22

33
# trigger on any push
4-
# but not on master or tag
4+
# but not on master, tags or readme modifications
55
on:
66
push:
77
tags-ignore:
88
- "**"
99
branches:
1010
- "**"
1111
- "!master"
12+
paths-ignore:
13+
- "!README.md"
1214

1315
env:
1416
ORGANIZATION: "zenika"
@@ -49,3 +51,28 @@ jobs:
4951
with:
5052
name: ${{ env.IMAGE_NAME }}-${{ env.BRANCH }}
5153
path: ${{ env.IMAGE_NAME }}-${{ env.BRANCH }}.tar
54+
55+
test:
56+
runs-on: ubuntu-latest
57+
needs: build
58+
59+
steps:
60+
- name: Checkout source
61+
uses: actions/checkout@master
62+
63+
- name: Save branch name as env var
64+
run: echo "::set-env name=BRANCH::${GITHUB_REF##*/}"
65+
66+
- name: Download image artifact
67+
uses: actions/download-artifact@v2
68+
with:
69+
name: ${{ env.IMAGE_NAME }}-${{ env.BRANCH }}
70+
71+
- name: Load image
72+
run: docker image load --input $IMAGE_NAME-$BRANCH.tar
73+
74+
- name: run structure tests
75+
uses: plexsystems/[email protected]
76+
with:
77+
image: ${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH }}
78+
config: tests/container-structure-test.yml

.github/workflows/push-latest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: push-latest
22

3-
# trigger on master
3+
# trigger on push to master
44
on:
55
push:
66
branches:

.github/workflows/release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: release
22

3-
# trigger on tag
3+
# trigger on published release
44
on:
5-
push:
6-
tags:
7-
- "*.*"
5+
release:
6+
types: [published]
87

98
env:
109
ORGANIZATION: "zenika"

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ RUN pip3 install cryptography==2.8
3838

3939
# Build final image
4040
FROM debian:buster-20191118-slim
41+
LABEL maintainer="bgauduch@github"
4142
ARG PYTHON_MAJOR_VERSION
4243
RUN apt-get update \
4344
&& apt-get install -y --no-install-recommends \

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![build](https://github.com/Zenika/terraform-azure-cli/workflows/build/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Abuild)
1+
[![build-test](https://github.com/Zenika/terraform-azure-cli/workflows/build-test/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Abuild-test)
22
[![push-latest](https://github.com/Zenika/terraform-azure-cli/workflows/push-latest/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Apush-latest)
33
[![release](https://github.com/Zenika/terraform-azure-cli/workflows/release/badge.svg)](https://github.com/Zenika/terraform-azure-cli/actions?query=workflow%3Arelease)
44
[![Docker Pulls](https://img.shields.io/docker/pulls/zenika/terraform-azure-cli.svg)](https://hub.docker.com/r/zenika/terraform-azure-cli/)
@@ -56,7 +56,7 @@ You can build the image locally directly from the Dockerfiles, using the build s
5656

5757
```bash
5858
# launch build script
59-
./dev-build.sh
59+
./scripts/dev-build.sh
6060
```
6161

6262
Optionally, it is possible to choose the tools desired versions using [Docker builds arguments](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) :
@@ -67,7 +67,7 @@ AZURE_CLI_VERSION=2.5.1
6767
TERRAFORM_VERSION=0.12.24
6868

6969
# launch the build script with parameters
70-
./dev-build.sh $AZURE_CLI_VERSION $TERRAFORM_VERSION
70+
./scripts/dev-build.sh $AZURE_CLI_VERSION $TERRAFORM_VERSION
7171
```
7272

7373
## 🙏 Roadmap & Contributions
File renamed without changes.

tests/container-structure-test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
schemaVersion: "2.0.0"
2+
3+
metadataTest:
4+
labels:
5+
- key: 'maintainer'
6+
value: 'bgauduch@github'
7+
cmd: ["bash"]
8+
workdir: "/workspace"
9+
10+
commandTests:
11+
- name: "Check Terraform CLI version"
12+
command: "terraform"
13+
args: ["version"]
14+
expectedOutput: ["Terraform v0.12.25"]
15+
- name: "Check Azure CLI version"
16+
command: "az"
17+
args: ["version"]
18+
expectedOutput: ["\"azure-cli\": \"2.5.1\""]

0 commit comments

Comments
 (0)