Skip to content

ci: correct multiline command #227

ci: correct multiline command

ci: correct multiline command #227

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
version:
description: Version to publish (3.8, all,...) (only one)
required: true
push:
branches:
- 'main'
- 'feature/*'
- 'feat/*'
jobs:
build:
runs-on: ubuntu-latest
env:
MYSQL_HOST: 127.0.0.1
MYSQL_DATABASE: test_db
MYSQL_USER: test_user
MYSQL_PASSWORD: password
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_PORT: 33061
MYSQL_8_HOST: 127.0.0.1
MYSQL_8_DATABASE: test_db
MYSQL_8_USER: test_user
MYSQL_8_PASSWORD: password
MYSQL_8_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_8_PORT: 33063
MARIADB_HOST: 127.0.0.1
MARIADB_DATABASE: test_db
MARIADB_USER: test_user
MARIADB_PASSWORD: password
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'yes'
MARIADB_PORT: 33062
MARIADB_MYSQL_LOCALHOST_USER: true
MARIADB_10_HOST: 127.0.0.1
MARIADB_10_DATABASE: test_db
MARIADB_10_USER: test_user
MARIADB_10_PASSWORD: password
MARIADB_10_ALLOW_EMPTY_ROOT_PASSWORD: 'yes'
MARIADB_10_PORT: 33064
MARIADB_10_MYSQL_LOCALHOST_USER: true
POSTGRES_HOST: 127.0.0.1
POSTGRES_DB: test_db
POSTGRES_USER: test_user
POSTGRES_PASSWORD: password
POSTGRES_PORT: 5432
MSSQL_HOST: 127.0.0.1
MSSQL_DATABASE: test_db
MSSQL_USER: sa
MSSQL_PASSWORD: yourStrong(!)Password
MSSQL_PORT: 1433
services:
# Label used to access the service container
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
MSSQL_SA_PASSWORD: ${{env.MSSQL_PASSWORD}}
ACCEPT_EULA: Y
ports:
- 1433:1433
# todo: dont hardcode password
# options: >-
# --health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P yourStrong(!)Password -Q 'SELECT 1' -b -o /dev/null"
# --health-interval 60s
# --health-timeout 30s
# --health-start-period 20s
# --health-retries 3
mysql:
image: mysql
env:
MYSQL_ALLOW_EMPTY_PASSWORD: ${{env.MYSQL_ALLOW_EMPTY_PASSWORD}}
MYSQL_USER: ${{env.MYSQL_USER}}
MYSQL_PASSWORD: ${{env.MYSQL_PASSWORD}}
MYSQL_ROOT_PASSWORD: ${{env.MYSQL_ROOT_PASSWORD}}
MYSQL_DATABASE: ${{env.MYSQL_DATABASE}}
ports:
- 33061:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
mysql-8:
image: mysql:8
env:
MYSQL_ALLOW_EMPTY_PASSWORD: ${{env.MYSQL_8_ALLOW_EMPTY_PASSWORD}}
MYSQL_USER: ${{env.MYSQL_8_USER}}
MYSQL_PASSWORD: ${{env.MYSQL_8_PASSWORD}}
MYSQL_ROOT_PASSWORD: ${{env.MYSQL_8_ROOT_PASSWORD}}
MYSQL_DATABASE: ${{env.MYSQL_8_DATABASE}}
ports:
- 33063:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
mariadb:
image: mariadb
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: ${{env.MARIADB_ALLOW_EMPTY_ROOT_PASSWORD}}
MARIADB_USER: ${{env.MARIADB_USER}}
MARIADB_PASSWORD: ${{env.MARIADB_PASSWORD}}
MARIADB_DATABASE: ${{env.MARIADB_DATABASE}}
MARIADB_MYSQL_LOCALHOST_USER: ${{env.MARIADB_MYSQL_LOCALHOST_USER}}
ports:
- 33062:3306
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
mariadb-10:
image: mariadb:10
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: ${{env.MARIADB_10_ALLOW_EMPTY_ROOT_PASSWORD}}
MARIADB_USER: ${{env.MARIADB_10_USER}}
MARIADB_PASSWORD: ${{env.MARIADB_10_PASSWORD}}
MARIADB_DATABASE: ${{env.MARIADB_10_DATABASE}}
MARIADB_MYSQL_LOCALHOST_USER: ${{env.MARIADB_10_MYSQL_LOCALHOST_USER}}
ports:
- 33064:3306
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres
env:
POSTGRES_DB: ${{env.POSTGRES_DB}}
POSTGRES_USER: ${{env.POSTGRES_USER}}
POSTGRES_PASSWORD: ${{env.POSTGRES_PASSWORD}}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
version: [ "3.8","3.9","3.10","3.11","3.12","3.13" ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '${{matrix.version}}/**'
docker:
- 'Dockerfile'
- name: Login to Docker Hub
uses: docker/login-action@v2
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Python Docker image
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: docker build ./${{matrix.version}} --tag my-temp-python-image:latest
- name: Set actual python version
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: echo "PYTHON_VERSION=$(docker run my-temp-python-image:latest python -V 2>&1 | grep -Po '(?<=Python )(.+)')" >> $GITHUB_ENV
- name: Build the Docker image
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: docker build . --tag orbisk/django-test:${{env.PYTHON_VERSION}} --tag orbisk/django-test:${{matrix.version}}
- name: Mysql Grant
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: |
echo "GRANT ALL on *.* to '${{env.MYSQL_USER}}';"| mysql -u root -h ${{env.MYSQL_HOST}} --port=${{env.MYSQL_PORT}}
- name: Mysql 8 Grant
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: |
echo "GRANT ALL on *.* to '${{env.MYSQL_8_USER}}';"| mysql -u root -h ${{env.MYSQL_8_HOST}} --port=${{env.MYSQL_8_PORT}}
- name: MariaDB Grant
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: |
echo "GRANT ALL on *.* to '${{env.MARIADB_USER}}';"| mysql -u root -h ${{env.MARIADB_HOST}} --port=${{env.MARIADB_PORT}}
- name: MariaDB 10 Grant
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: |
echo "GRANT ALL on *.* to '${{env.MARIADB_10_USER}}';"| mysql -u root -h ${{env.MARIADB_10_HOST}} --port=${{env.MARIADB_10_PORT}}
- name: Test Databases
if: steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version
run: |
docker run --network host -v /"$(pwd)/tests":/app -w /app \
-e MYSQL_HOST \
-e MYSQL_DATABASE \
-e MYSQL_USER \
-e MYSQL_PORT \
-e MYSQL_PASSWORD \
-e MYSQL_8_HOST \
-e MYSQL_8_DATABASE \
-e MYSQL_8_USER \
-e MYSQL_8_PORT \
-e MYSQL_8_PASSWORD \
-e MARIADB_HOST \
-e MARIADB_DATABASE \
-e MARIADB_USER \
-e MARIADB_PORT \
-e MARIADB_PASSWORD \
-e MARIADB_10_HOST \
-e MARIADB_10_DATABASE \
-e MARIADB_10_USER \
-e MARIADB_10_PORT \
-e MARIADB_10_PASSWORD \
-e POSTGRES_HOST \
-e POSTGRES_DB \
-e POSTGRES_USER \
-e POSTGRES_PORT \
-e POSTGRES_PASSWORD \
-e MSSQL_HOST \
-e MSSQL_PORT \
-e MSSQL_DATABASE \
-e MSSQL_USER \
-e MSSQL_PASSWORD \
orbisk/django-test:${{env.PYTHON_VERSION}} sh -c "cd /app && pip install -r requirements.txt && python manage.py test"
- name: Push Image
if: (steps.changes.outputs.src == 'true' || steps.changes.outputs.docker == 'true' || github.event.inputs.version == 'all' || github.event.inputs.version == matrix.version) && github.ref == 'refs/heads/main'
run: docker push -a orbisk/django-test