Skip to content

Commit

Permalink
Added additional image build for acceptance testing (#9)
Browse files Browse the repository at this point in the history
* Added additional image build for acceptance testing

* fix: run DESIGN_PLONE_POLICY_ACCEPTANCE_TESTING by default

* branch name as docker label

* use dockerfile.acceptance

* fix: dockerfile

* extract branch name

---------

Co-authored-by: Mauro Amico <[email protected]>
  • Loading branch information
pnicolli and mamico authored Nov 7, 2023
1 parent d55e58b commit 5909807
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
52 changes: 51 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ jobs:
IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]')
echo ::set-output name=IMAGE_ID::$IMAGE_ID
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Get the version
id: get_version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION="${{ steps.extract_branch.outputs.branch }}"
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo ::set-output name=VERSION::$VERSION
Expand Down Expand Up @@ -78,3 +83,48 @@ jobs:
--form ref=main \
--form "variables[GITHUB_TAG]=${{ steps.get_version.outputs.VERSION }}" \
"https://gitlab.com/api/v4/projects/${{ secrets.PROJECT_ID }}/trigger/pipeline"
build-acceptance-image:
name: Build docker image for acceptance tests
runs-on: ubuntu-latest

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get the image id
id: get_image_id
run: |
IMAGE_ID=$(echo ghcr.io/${{ github.repository }}-acceptance | tr '[A-Z]' '[a-z]')
echo ::set-output name=IMAGE_ID::$IMAGE_ID
- name: Get the version
id: get_version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo ::set-output name=VERSION::$VERSION
- name: Build and push container image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.acceptance
push: true
tags: ${{ steps.get_image_id.outputs.IMAGE_ID }}:${{ steps.get_version.outputs.VERSION }}
platforms: linux/amd64,linux/arm64
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pyvenv.cfg
/var
/src/*
Pipfile*
.python-version
10 changes: 10 additions & 0 deletions Dockerfile.acceptance
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM plone/server-acceptance:6.0.4
COPY docker/create-constraints.py docker/*.cfg docker/*.txt /app/
COPY versions.cfg /
RUN pip install -r https://dist.plone.org/release/6.0.4/requirements.txt ${PIP_PARAMS} && \
python create-constraints.py constraints.cfg constraints.txt && \
./bin/pip install --ignore-requires-python -r requirements-acceptance.txt -c constraints.txt ${PIP_PARAMS} && \
find /app/lib -name LC_MESSAGES -exec chown -R plone:plone {} \;

# Run DESIGN_PLONE_POLICY_ACCEPTANCE_TESTING by default
CMD ["design.plone.policy.testing.DESIGN_PLONE_POLICY_ACCEPTANCE_TESTING"]
3 changes: 3 additions & 0 deletions docker/requirements-acceptance.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Plone
design.plone.policy[test]
collective.MockMailHost

0 comments on commit 5909807

Please sign in to comment.