Update github actions 8 #244
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
env: | |
COVERAGE_THRESHOLD: 95 | |
DOCKER_IMAGE_REPO: bandirom/django-template | |
on: | |
workflow_call: | |
push: | |
branches-ignore: | |
- master | |
tags-ignore: | |
- v* | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: "Build dev image" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Set environment docker tag | |
id: set-docker-tag | |
run: | | |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}") | |
echo "DOCKER_TAG=${BRANCH_NAME}" >> $GITHUB_ENV | |
- name: Set environment docker image | |
run: echo "DOCKER_IMAGE=${{ env.DOCKER_IMAGE_REPO }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build dev version with cache | |
uses: docker/[email protected] | |
with: | |
context: . | |
tags: ${{ env.DOCKER_IMAGE }} | |
file: docker/dev/web/Dockerfile | |
# push: true | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }} | |
cache-to: type=inline | |
test: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
env: | |
SECRET_KEY: dummy | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
POSTGRES_HOST: postgres | |
POSTGRES_PORT: 5432 | |
steps: | |
- name: Set environment docker tag | |
run: | | |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}") | |
echo "DOCKER_TAG=${BRANCH_NAME}" >> $GITHUB_ENV | |
- name: Set environment docker image | |
run: echo "DOCKER_IMAGE=${{ env.DOCKER_IMAGE_REPO }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV | |
- name: Pull Docker image | |
run: docker pull ${{ env.DOCKER_IMAGE }} | |
- name: Migration check | |
run: docker run --entrypoint="" ${{ env.DOCKER_IMAGE }} python manage.py makemigrations --check | |
- name: Tests | |
run: docker run --entrypoint="" ${{ env.DOCKER_IMAGE }} pytest | |
services: | |
postgres: | |
image: postgres:15.1-alpine | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
POSTGRES_PASSWORD: postgres | |
test_isort: | |
runs-on: ubuntu-latest | |
steps: | |
- name: CheckOut Repo | |
uses: actions/checkout@v4 | |
- name: Run isort | |
run: | | |
pip install isort | |
cd web | |
isort . --check | |
test_black: | |
runs-on: ubuntu-latest | |
steps: | |
- name: CheckOut Repo | |
uses: actions/checkout@v4 | |
- name: Run black | |
id: tests | |
run: | | |
pip install black | |
cd web | |
black . --check | |
test_flake8: | |
runs-on: ubuntu-latest | |
steps: | |
- name: CheckOut Repo | |
uses: actions/checkout@v4 | |
- name: Run Flake8 | |
run: | | |
pip install flake8 | |
cd web | |
flake8 . |