This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
Fix CI/CD #23
This file contains 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: Build and Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request_target: | |
branches: | |
- main | |
jobs: | |
build_test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
if: ${{ github.event_name == 'push' }} | |
uses: actions/checkout@v3 | |
- name: Checkout PR | |
if: ${{ github.event_name == 'pull_request_target' }} | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install Python 3 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11.9 | |
- name: Run services on docker compose | |
run: docker compose up -d postgres redis | |
- name: List services for tests | |
run: docker ps | |
- name: Build Image | |
id: build | |
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ env.IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=ref,event=tag | |
cache: false | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
- name: Run tests with pytest and generate report | |
run: | | |
docker run \ | |
--name airflowdags \ | |
--network=host \ | |
-v "$(pwd)"/tests:/opt/airflow/tests \ | |
-v "$(pwd)"/dags:/opt/airflow/dags \ | |
-v "$(pwd)"/airflow.cfg:/opt/airflow/airflow.cfg \ | |
-v "$(pwd)"/data:/opt/airflow/data \ | |
$REGISTRY/$IMAGE@${{ steps.build.outputs.image-digest }} \ | |
bash -c "airflow db init && \ | |
airflow webserver -D && \ | |
airflow scheduler -D && \ | |
airflow triggerer -D && \ | |
airflow celery worker -D && \ | |
airflow celery flower -D && \ | |
pytest /opt/airflow/tests" | |
- name: Deploy QA | |
if: ${{ github.event_name == 'push' }} | |
uses: cern-sis/gh-workflows/.github/actions/kubernetes-project-new-images@v6 | |
with: | |
event-type: update | |
images: registry.cern.ch/cern-sis/inspire/workflows@${{ steps.build.outputs.image-digest }} | |
token: ${{ secrets.PAT_FIRE_EVENTS_ON_CERN_SIS_KUBERNETES }} |