Testing pull_request_target #53
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 & test Airflow | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
pull_request_target: | |
types: [labeled] | |
workflow_dispatch: | |
jobs: | |
build: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
if: (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe to test')) | |
|| github.event_name == 'pull_request' || github.event_name == 'push' | |
steps: | |
- name: Checkout Code | |
if: github.event_name == 'pull_request_target' || contains(github.event.pull_request.labels.*.name, 'safe to test') | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Checkout Code for Push | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt build | |
python -m build | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DUSERNAME }} | |
password: ${{ secrets.DPASSWORD }} | |
- name: Install & Run Airflow | |
run: | | |
PYPACKAGE=$(ls dist | grep .whl) | |
cp "dist/${PYPACKAGE}" tests_integration/plugins/ | |
cd tests_integration | |
echo "FROM apache/airflow:2.9.1" > Dockerfile | |
echo "ADD plugins/${PYPACKAGE} ." >> Dockerfile | |
echo "RUN pip install ${PYPACKAGE}" >> Dockerfile | |
echo -e "AIRFLOW_UID=$(id -u)" > .env | |
docker compose up -d airflow-init | |
docker compose up -d --build | |
- name: Add TM1 connection to Airflow | |
run: | | |
DOCKID=$(docker ps -q --filter "name=tests_integration-airflow-worker-1") | |
docker exec $DOCKID airflow connections add tm1_conn --conn-type tm1 --conn-login admin --conn-host tm1-centos7 --conn-port 5360 --conn-schema "" --conn-extra "" | |
- name: Test Airflow TM1 provider | |
run: | | |
cd tests_integration | |
echo "Running tests..." | |
pip install pytest | |
pytest integration_test.py -s | |
- name: Archive production artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: integration-test-logs | |
path: | | |
tests_integration/logs/* | |
tests_integration/tm1models/24Retail/tm1server.log | |
tests_integration/tm1models/24Retail/tm1processerror*.log | |
- name: Stop docker containers | |
if: always() | |
run: | | |
cd tests_integration | |
docker compose down | |