Skip to content

Commit

Permalink
new ci test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed May 4, 2024
1 parent 698033a commit 5960527
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: ci

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build PDK Container
id: build
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: puppet/pdk:${{ github.sha }}

- name: Test with no workspace volume
run: |
if docker run --rm ${{ steps.build.outputs.imageid }} --version 2>"$GITHUB_WORKSPACE/.errout" ; then
echo '::error::expected an error that was not returned'
exit 1
fi
grep -s 'error: /workspace in the container is not mounted' < "$GITHUB_WORKSPACE/.errout"
- name: Test with a workspace volume
run: |
docker run --rm -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} --version 2>"$GITHUB_WORKSPACE/.errout" | grep -E '^[[:digit:]\.]+$'
grep -s 'mount a volume to /cache in the container to improve performance' < "$GITHUB_WORKSPACE/.errout"
- name: Test create new module
run: |
WORKSPACE_OWNER="$(stat -c '%u:%g' .)"
docker run --rm -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} new module dockertest --skip-interview
if [ "${WORKSPACE_OWNER}" != "$(stat -c '%u:%g' dockertest)" ] ; then
echo "::error::pdk in container failed to run with same uid and gid of host workspace"
exit 1
fi
cd dockertest
docker run --rm -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} new class test
docker run --rm -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} validate
docker run --rm -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} test unit
- name: Test running with root workspace
run: |
sudo cp -r dockertest roottest
cd roottest
docker run --rm -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} new class root
- name: Test running with workspace ownership not matching user
run: |
cd roottest
if docker run --rm --user $UID:$GID -v `pwd`:/workspace ${{ steps.build.outputs.imageid }} new class root 2>"$GITHUB_WORKSPACE/.errout" ; then
echo '::error::expected an error that was not returned'
exit 1
fi
grep -s 'error: unable to write to /workspace' < "$GITHUB_WORKSPACE/.errout"
- name: Test deprecated /root volume
run: |
cd roottest
docker run --rm -v `pwd`:/root ${{ steps.build.outputs.imageid }} new class toor 2>"$GITHUB_WORKSPACE/.errout"
grep -s 'mounting a volume to /root in the container is deprecated' < "$GITHUB_WORKSPACE/.errout"

0 comments on commit 5960527

Please sign in to comment.