From bb76fee1d0b10ee8cf5588a4c9c64460d2776a38 Mon Sep 17 00:00:00 2001 From: Hugo Bollon Date: Thu, 18 Jul 2024 16:39:50 +0200 Subject: [PATCH] ci: add tests workflow --- .github/workflows/tests.yml | 65 +++++++++++++++++++++++++++++++++++++ ci/requirements.txt | 1 + 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/tests.yml create mode 100644 ci/requirements.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..4c659862 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,65 @@ +name: Python unit tests + +on: + push: + pull_request: + +env: + HAS_SECRETS: ${{ secrets.HAS_SECRETS }} + +jobs: + tests: + name: Execute unit tests + strategy: + matrix: + python-version: [3.12] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Initialise gopass + uses: camptocamp/initialise-gopass-summon-action@v2 + with: + ci-gpg-private-key: ${{secrets.CI_GPG_PRIVATE_KEY}} + github-gopass-ci-token: ${{secrets.GOPASS_CI_GITHUB_TOKEN}} + if: env.HAS_SECRETS == 'HAS_SECRETS' + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Upgrade pip version + run: | + python -m pip install -U pip + + - run: echo "${HOME}/.local/bin" >> ${GITHUB_PATH} + + - name: Install CI dependencies + run: python3 -m pip install --user --requirement=ci/requirements.txt + + - name: Environment information + run: c2cciutils-env + env: + GITHUB_EVENT: ${{ toJson(github) }} + + - name: Copy .env file + run: cp .env.sample .env + + - name: Prepare Docker images and start Compose environment + run: make prepare_env + + - name: Run tests + run: make test + + - name: Docker logs + run: c2cciutils-docker-logs + + - name: Stop Compose environment + run: make destroy_env diff --git a/ci/requirements.txt b/ci/requirements.txt new file mode 100644 index 00000000..140d774a --- /dev/null +++ b/ci/requirements.txt @@ -0,0 +1 @@ +c2cciutils[checks,publish]==1.6.21