|
| 1 | +name: "Scheduled Testing / Staging" |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 * * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + test-scheduled-main: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + id-token: write |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 17 | + with: |
| 18 | + ref: feat/api-1_0_0_beta_7 |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Install uv |
| 22 | + uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0 |
| 23 | + with: |
| 24 | + version-file: "pyproject.toml" |
| 25 | + enable-cache: true |
| 26 | + cache-dependency-glob: uv.lock |
| 27 | + |
| 28 | + - name: Install dev tools |
| 29 | + shell: bash |
| 30 | + run: .github/workflows/_install_dev_tools.bash |
| 31 | + |
| 32 | + - name: Install Python, venv and dependencies |
| 33 | + shell: bash |
| 34 | + run: uv sync --all-extras --frozen --link-mode=copy |
| 35 | + |
| 36 | + - name: Create .env file |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + cat > .env << EOF |
| 40 | + AIGNOSTICS_API_ROOT=https://platform-staging.aignostics.com |
| 41 | + AIGNOSTICS_CLIENT_ID_DEVICE=${{ secrets.AIGNOSTICS_CLIENT_ID_DEVICE_STAGING }} |
| 42 | + AIGNOSTICS_REFRESH_TOKEN=${{ secrets.AIGNOSTICS_REFRESH_TOKEN_STAGING }} |
| 43 | + EOF |
| 44 | +
|
| 45 | + - name: Set up GCP credentials for bucket access |
| 46 | + shell: bash |
| 47 | + env: |
| 48 | + GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS_STAGING }} |
| 49 | + run: | |
| 50 | + echo "$GCP_CREDENTIALS" | base64 -d > credentials.json |
| 51 | + echo "GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/credentials.json" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + - name: Test / scheduled |
| 54 | + env: |
| 55 | + BETTERSTACK_HEARTBEAT_URL: "${{ secrets.BETTERSTACK_HEARTBEAT_URL_STAGING }}" |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + set +e |
| 59 | + make test_scheduled |
| 60 | + EXIT_CODE=$? |
| 61 | + # Show test execution in GitHub Job summary |
| 62 | + found_files=0 |
| 63 | + for file in reports/pytest_*.md; do |
| 64 | + if [ -f "$file" ]; then |
| 65 | + cat "$file" >> $GITHUB_STEP_SUMMARY |
| 66 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 67 | + found_files=1 |
| 68 | + fi |
| 69 | + done |
| 70 | + if [ $found_files -eq 0 ]; then |
| 71 | + echo "# All scheduled tests passed" >> $GITHUB_STEP_SUMMARY |
| 72 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 73 | + fi |
| 74 | + # Show test coverage in GitHub Job summary |
| 75 | + if [ -f "reports/coverage.md" ]; then |
| 76 | + cat "reports/coverage.md" >> $GITHUB_STEP_SUMMARY |
| 77 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 78 | + else |
| 79 | + echo "# No test coverage computed." >> $GITHUB_STEP_SUMMARY |
| 80 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 81 | + fi |
| 82 | + # Provide heartbeat to BetterStack for monitoring/alerting if heartbeat url is configured as secret |
| 83 | + if [ -n "$BETTERSTACK_HEARTBEAT_URL" ]; then |
| 84 | + BETTERSTACK_METADATA_PAYLOAD=$(jq -n \ |
| 85 | + --arg github_workflow "${{ github.workflow }}" \ |
| 86 | + --arg github_run_url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ |
| 87 | + --arg github_run_id "${{ github.run_id }}" \ |
| 88 | + --arg github_job "${{ github.job }}" \ |
| 89 | + --arg github_sha "${{ github.sha }}" \ |
| 90 | + --arg github_actor "${{ github.actor }}" \ |
| 91 | + --arg github_repository "${{ github.repository }}" \ |
| 92 | + --arg github_ref "${{ github.ref }}" \ |
| 93 | + --arg job_status "${{ job.status }}" \ |
| 94 | + --arg github_event_name "${{ github.event_name }}" \ |
| 95 | + --arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ |
| 96 | + '{ |
| 97 | + github: { |
| 98 | + workflow: $github_workflow, |
| 99 | + run_url: $github_run_url, |
| 100 | + run_id: $github_run_id, |
| 101 | + job: $github_job, |
| 102 | + sha: $github_sha, |
| 103 | + actor: $github_actor, |
| 104 | + repository: $github_repository, |
| 105 | + ref: $github_ref, |
| 106 | + event_name: $github_event_name |
| 107 | + }, |
| 108 | + job: { |
| 109 | + status: $job_status, |
| 110 | + }, |
| 111 | + timestamp: $timestamp, |
| 112 | + }' |
| 113 | + ) |
| 114 | + curl \ |
| 115 | + --fail-with-body \ |
| 116 | + --silent \ |
| 117 | + --request POST \ |
| 118 | + --header "Content-Type: application/json" \ |
| 119 | + --data-binary "${BETTERSTACK_METADATA_PAYLOAD}" \ |
| 120 | + "${BETTERSTACK_HEARTBEAT_URL}/${EXIT_CODE}" |
| 121 | + echo "INFO: Sent heartbeat to betterstack with exit code '${EXIT_CODE}'" |
| 122 | + else |
| 123 | + echo "WARNING: No BetterStack heartbeat URL configured, skipped heartbeat notification." |
| 124 | + fi |
| 125 | + exit $EXIT_CODE |
| 126 | +
|
| 127 | + - name: Upload test results |
| 128 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 129 | + if: always() |
| 130 | + with: |
| 131 | + name: test-results-scheduled-main |
| 132 | + path: | |
| 133 | + reports/junit.xml |
| 134 | + reports/coverage.xml |
| 135 | + reports/coverage.md |
| 136 | + reports/coverage_html |
| 137 | + aignostics.log |
| 138 | + retention-days: 7 |
0 commit comments