Skip to content

CI

CI #2635

Workflow file for this run

name: CI
on:
- push
- workflow_dispatch
jobs:
scrapers:
runs-on: ubuntu-latest
defaults:
run:
working-directory: scrapers
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v2
- name: Cache python packages
uses: actions/cache@v2
env:
cache-name: cache-python-packages
with:
path: ${{ env.HOME }}/.cache/pypoetry
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
- name: Install poetry
run: pip install poetry
- name: Install dependencies
run: poetry install
- name: Lint with flake8
run: make lint
- name: Check types with mypy
run: make types
- name: Test with pytest
run: make tests
- name: Convert coverage report to XML
run: make coverage
- name: Upload coverage report to codecov.io
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./scrapers/coverage.xml
flags: scrapers
app:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
services:
mariadb:
image: mariadb:10.5.5
ports:
- '3306:3306'
env:
MYSQL_DATABASE: tests
MYSQL_USER: laravel
MYSQL_PASSWORD: laravel
MYSQL_ROOT_PASSWORD: laravel
options: >-
--health-cmd="mariadb-admin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
APP_ENV: testing
# Use this key for testing purposes only
APP_KEY: base64:aZ+X6o+vmxSZD8RtLYTpQ5NlQ7SXOgmz5CYjG9faFdU=
DB_USERNAME: laravel
DB_PASSWORD: laravel
DB_HOST: '127.0.0.1'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov
- uses: actions/checkout@v2
- name: Cache php packages
uses: actions/cache@v2
env:
cache-name: cache-php-packages
with:
path: ./vendor
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
- name: Install PHP dependencies
run: composer install --no-interaction
- name: Install Node.js dependencies
run: npm ci
- name: Build frontend assets
run: npm run prod
- name: Check code style with PHP CS Fixer
run: composer cs
- name: Test with pest
run: composer test-with-coverage
- name: Upload coverage report to codecov.io
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./app/coverage.xml
flags: app
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm ci
- name: Check formatting with Prettier
run: npm run prettier
deploy:
needs: [app, scrapers, frontend]
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
concurrency: deployment
defaults:
run:
working-directory: ansible
steps:
- uses: actions/checkout@v2
- run: |
mkdir ~/.ssh
echo "${{ secrets.EPVPROD_PUBLIC}}" >> ~/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Cache Ansible installation
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-ansible
- name: Install Ansible
run: pip3 install ansible
- name: Install Ansible collection
run: ansible-galaxy collection install community.general
- name: Create Ansible Vault password file
run: echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > ansible-vault.pass
- name: Run Ansible playbook
run: ansible-playbook site.yml -i ./hosts --vault-password-file ansible-vault.pass
- name: Delete secret files
run: rm ansible-vault.pass && rm ~/.ssh/id_rsa