Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run e2e tests in CI #44

Merged
merged 20 commits into from
Apr 30, 2024
Merged
25 changes: 0 additions & 25 deletions .env.example

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/docker-image.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Docker Image CI

on: [push]

jobs:

build-test-release:
name: Build, Test and Release

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install pose
run: |
wget https://github.com/mrsarm/pose/releases/download/0.4.0/pose-0.4.0-x86_64-unknown-linux-gnu.tar.gz -O - \
| tar -xz

- name: Define $TAG variable
run: echo "TAG=$(./pose slug $GITHUB_REF_NAME)" >> "$GITHUB_ENV"
- name: Print tag and image names
run: echo -e "- TAG --> $TAG\n- IMAGE --> mrsarm/django-coleman:$TAG"

- name: Build the Docker image
run: ./docker-build.sh $TAG

- name: Run tests
run: docker run --rm -e PROCESS_TYPE=test --name django-coleman "mrsarm/django-coleman:$TAG"

- name: Release Docker image
run: docker push "mrsarm/django-coleman:$TAG"

- name: Get compose.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./pose get -H "Authorization: token $GITHUB_TOKEN" \
"https://raw.githubusercontent.com/mrsarm/dcoleman-e2e/$TAG/compose.yaml" "$TAG:main"
- name: Get .env.example
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./pose get -H "Authorization: token $GITHUB_TOKEN" \
"https://raw.githubusercontent.com/mrsarm/dcoleman-e2e/$TAG/.env.example" "$TAG:main"

- name: Setup environment variables
run: cp .env.example .env

- name: Build compose file for CI
if: ${{ github.ref != 'refs/heads/master' }}
run: |
./pose --no-docker config --tag $TAG --tag-filter regex=mrsarm/ --progress -o ci.yaml

- name: Pull images
run: docker compose -f ci.yaml pull
&& docker compose -f ci.yaml pull dcoleman-e2e # services with profiles are not pulled by default

- name: Run e2e tests
run: docker compose -f ci.yaml run dcoleman-e2e

- name: Tag "latest"
if: ${{ github.ref == 'refs/heads/master' }}
run: docker tag "mrsarm/django-coleman:$TAG" mrsarm/django-coleman:latest
- name: Release "latest"
if: ${{ github.ref == 'refs/heads/master' }}
run: docker push mrsarm/django-coleman:latest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ venv*/

/htmlcov
/.coverage

ci*.yaml
23 changes: 15 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Features
* Pytest with some tests as example and code coverage reports configured.
* Docker and Docker Compose configurations (images published in
`Docker Hub <https://hub.docker.com/r/mrsarm/django-coleman>`_).
* CI environment, and E2E tests written with Playwright:
`dcoleman-e2e <https://github.com/mrsarm/dcoleman-e2e>`_. CI is executed with
GitHub Actions, and executed on each push in this project,
the viewer repo, or the E2E repo itself. The task also releases the image
in the Docker Registry.
* Ready to use "production" configurations as reference.

.. image:: docs/source/_static/img/django-coleman.png
Expand Down Expand Up @@ -117,21 +122,23 @@ Docker
A reference `<Dockerfile>`_ is provided, and the image published
in `Docker Hub <https://hub.docker.com/r/mrsarm/django-coleman>`_.

Also `<compose.yml>`_ and `<.env.example>`_ files are provided, you can run
all from here, Django Coleman, the viewer app and Postgres.
Also ``compose.yaml`` and ``.env.example`` files are provided in the
`dcoleman-e2e <https://github.com/mrsarm/dcoleman-e2e>`_ project, you
can run all from there, Django Coleman, the viewer app and Postgres,
and the E2E tests.

First, copy the ``.env.example`` file as ``.env`` file, and edit whatever
value you want to::
First, copy the ``.env.example`` file as ``.env`` files from the E2E repo,
and edit whatever value you want to::

$ cp .env.example .env
$ cp ../dcoleman-e2e/.env.example .env

Then before run for the first time the containers, you have to either
download the images from Docker Hub or build them from the source code. To
build the images from the source code, execute::

$ docker compose build
$ ./docker-build.sh

Or to get the images from Docker Hub, execute::
Or to get the images from Docker Hub, execute from the dcoleman-e2e repo::

$ docker compose pull

Expand Down Expand Up @@ -300,6 +307,6 @@ About

**Project**: https://github.com/mrsarm/django-coleman

**Authors**: (2017-2023) Mariano Ruiz <[email protected]>
**Authors**: (2017-2024) Mariano Ruiz <[email protected]>

**License**: AGPL-v3
159 changes: 0 additions & 159 deletions compose.yml

This file was deleted.