Skip to content

Commit

Permalink
container test
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-ssd authored and Sida Say committed Feb 1, 2023
1 parent 3a205bd commit 0694b62
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Build
name: Build Release

# Controls when the action will run.
on:
Expand All @@ -14,16 +14,15 @@ on:
jobs:
# This workflow contains a single job called "build"
build:
name: Build container images
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4.3.0
with:
Expand All @@ -37,20 +36,17 @@ jobs:
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
Expand Down
39 changes: 24 additions & 15 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR Build
name: Build PR

# Controls when the action will run.
on:
Expand All @@ -14,16 +14,14 @@ on:
jobs:
# This workflow contains a single job called "build"
build:
name: Build container images
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4.3.0
with:
Expand All @@ -32,21 +30,32 @@ jobs:
khalibre/privacyidea
# add git short SHA as Docker tag
tags: |
# minimal (short sha)
type=sha
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build
- name: Build
uses: docker/build-push-action@v4
with:
context: .
push: false
platforms: linux/amd64,linux/arm64
load: true
platforms: linux/amd64
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Seup Container Structure Tests
run: |
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64
chmod +x container-structure-test-linux-amd64
mkdir -p $HOME/.local/bin
mv container-structure-test-linux-amd64 $HOME/.local/bin/container-structure-test
- name: Run Container Structure Tests
run: container-structure-test test --image ${{ env.DOCKER_METADATA_OUTPUT_TAGS }} --config structure-tests.yaml -o junit --test-report structure-tests-report.xml
- name: Upload Test Report
uses: actions/upload-artifact@v3
if: always() # always run even if the previous step fails
with:
name: junit-test-results
path: 'structure-tests-report.xml'
retention-days: 1
5 changes: 3 additions & 2 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: report
name: Container Strcuture Tests Report
on:
workflow_run:
workflows: [PR Build]
workflows: [Build PR]
types: [completed]

permissions:
checks: write

jobs:
checks:
name: Checking report
runs-on: ubuntu-latest
steps:
- name: Download Test Report
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.swp
secretkey
pipepper
structure-tests-report.xml
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ cleanup:
docker stop privacyidea-dev || true
docker rm privacyidea-dev || true
sudo rm -rf $(LOCAL_DATA_VOLUME)

test:
container-structure-test test --image khalibre/privacyidea:dev --config structure-tests.yaml
4 changes: 2 additions & 2 deletions structure-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
schemaVersion: 2.0.0

metadataTest:
env:
envVars:
- key: UWSGI_INI
value: "/etc/uwsgi/uwsgi.ini"
- key: UWSGI_CHEAPER
value: "2"
- key: UWSGI_PROCESSES
value: "16"
- key: NGINX_MAX_UPLOAD
value: "100m"
value: "1m"
- key: NGINX_WORKER_PROCESSES
value: "1"
- key: NGINX_SERVER_TOKENS
Expand Down

0 comments on commit 0694b62

Please sign in to comment.