Skip to content

Integration Tests of MIP Federations #662

Integration Tests of MIP Federations

Integration Tests of MIP Federations #662

name: Integration Tests of MIP Federations
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
# Runs "at 6:55am every day" (see https://crontab.guru)
- cron: '55 6 * * *'
jobs:
build-test-report:
runs-on: ubuntu-latest
environment: Integration test pipeline # TO INHERIT SECRETS
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Install JQ
if: success() || failure()
run: sudo apt-get install jq
-
name: Setup project parameters
run: |
cat << EOF > $(pwd)/tests/project_parameters.py
UserID = "$EBRAINSUSERID"
UserPWD = "$EBRAINSUSERPWD"
EOF
cat $(pwd)/tests/project_parameters.py
env:
EBRAINSUSERID: ${{ secrets.EBRAINSUSERID }}
EBRAINSUSERPWD: ${{ secrets.EBRAINSUSERPWD }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: pytest_mip:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
-
name: Get current date
run: |
echo "current_date=$(date +%d-%m-%Y-%H-%M)" >> $GITHUB_ENV
echo "current_date_fmt=$(date '+%d-%m-%Y %H:%M')" >> $GITHUB_ENV
-
name: Run integration tests of the up-and-running MIP federations
run: |
mkdir -p report/report-${{ env.current_date }}
docker run -v $(pwd)/report/report-${{ env.current_date }}:/app/report -t pytest_mip .
mv $(pwd)/report/report-${{ env.current_date }}/report.html $(pwd)/report/report-${{ env.current_date }}/index.html
-
name: Update Reports JSON (SUCCESS)
if: success()
run: |
# read the existing JSON content
json=$(curl -s "https://hbpmedical.github.io/pytest-mip/reports.json")
# create a new JSON object to append
new_record=$(echo "{\"date\": \"${{ env.current_date_fmt }}\", \"link\": \"https://hbpmedical.github.io/pytest-mip/report-${{ env.current_date }}\", \"junitxml\": \"https://hbpmedical.github.io/pytest-mip/report-${{ env.current_date }}/junit-report.xml\", \"status\": \"0\"}")
# append the new record to the "reports" array
json=$(echo $json | jq ".reports += [$new_record]")
# write the updated JSON content back to the file
echo $json > $(pwd)/report/reports.json
-
name: Update Reports JSON (FAILURE)
if: failure()
run: |
# read the existing JSON content
json=$(curl -s "https://hbpmedical.github.io/pytest-mip/reports.json")
# create a new JSON object to append
new_record=$(echo "{\"date\": \"${{ env.current_date_fmt }}\", \"link\": \"https://hbpmedical.github.io/pytest-mip/report-${{ env.current_date }}\", \"junitxml\": \"https://hbpmedical.github.io/pytest-mip/report-${{ env.current_date }}/junit-report.xml\", \"status\": \"1\"}")
# append the new record to the "reports" array
json=$(echo $json | jq ".reports += [$new_record]")
# write the updated JSON content back to the file
echo $json > $(pwd)/report/reports.json
-
name: Deploy report to GitHub Page
uses: peaceiris/actions-gh-pages@v3
if: success() || failure()
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: report
keep_files: true