diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a08828a..8997d4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 2b29e9e..fd09e75 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ pyvenv.cfg /var /src/* Pipfile* +.python-version diff --git a/Dockerfile.acceptance b/Dockerfile.acceptance new file mode 100644 index 0000000..0723da9 --- /dev/null +++ b/Dockerfile.acceptance @@ -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"] diff --git a/docker/requirements-acceptance.txt b/docker/requirements-acceptance.txt new file mode 100644 index 0000000..48543ef --- /dev/null +++ b/docker/requirements-acceptance.txt @@ -0,0 +1,3 @@ +Plone +design.plone.policy[test] +collective.MockMailHost