empty trigger #7
Workflow file for this run
This file contains hidden or 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: tilegym-build-and-test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - "pull-request/[0-9]+" | |
| env: | |
| IMAGE_NAME: tilegym-transformers | |
| jobs: | |
| config: | |
| name: parse-ci-config | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build: ${{ steps.parse.outputs.build }} | |
| run_ops: ${{ steps.parse.outputs.run_ops }} | |
| run_benchmark: ${{ steps.parse.outputs.run_benchmark }} | |
| image_tag: ${{ steps.parse.outputs.image_tag }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get PR info | |
| id: pr | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| let prBody = ''; | |
| let prNumber = ''; | |
| const branchName = context.ref.replace('refs/heads/', ''); | |
| core.info(`Looking for PR for branch: ${branchName}`); | |
| // Try method 1: Extract PR number from branch name | |
| const branchMatch = branchName.match(/^pull-request\/(\d+)/); | |
| if (branchMatch) { | |
| prNumber = branchMatch[1]; | |
| core.info(`Extracted PR #${prNumber} from branch name`); | |
| // Fetch PR body by number | |
| try { | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: parseInt(prNumber), | |
| }); | |
| prBody = pr.body || ''; | |
| core.info(`Fetched PR body (${prBody.length} characters)`); | |
| } catch (error) { | |
| core.warning(`Failed to fetch PR #${prNumber}: ${error.message}`); | |
| } | |
| } else { | |
| // Try method 2: Search by branch name | |
| try { | |
| const { data: prs } = await github.rest.pulls.list({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| head: `${context.repo.owner}:${branchName}`, | |
| }); | |
| if (prs.length > 0) { | |
| prBody = prs[0].body || ''; | |
| prNumber = prs[0].number.toString(); | |
| core.info(`Found PR #${prNumber} via API search`); | |
| core.info(`PR body length: ${prBody.length} characters`); | |
| } else { | |
| core.info(`No open PR found for branch ${branchName}`); | |
| } | |
| } catch (error) { | |
| core.warning(`Error searching for PR: ${error.message}`); | |
| } | |
| } | |
| return { prBody, prNumber }; | |
| - name: Parse config and set image tag | |
| id: parse | |
| env: | |
| PR_BODY: ${{ fromJSON(steps.pr.outputs.result).prBody }} | |
| PR_NUMBER: ${{ fromJSON(steps.pr.outputs.result).prNumber }} | |
| run: | | |
| # Parse CI config from PR body | |
| pip install pyyaml --quiet | |
| python3 .github/scripts/parse_pr_config.py | |
| # Set image tag based on PR number | |
| if [ -n "$PR_NUMBER" ]; then | |
| echo "image_tag=pr-${PR_NUMBER}" >> $GITHUB_OUTPUT | |
| echo "Using image tag: pr-${PR_NUMBER}" | |
| else | |
| echo "image_tag=latest" >> $GITHUB_OUTPUT | |
| echo "Using image tag: latest" | |
| fi | |
| build: | |
| name: build-tilegym-transformers-image | |
| needs: config | |
| if: needs.config.outputs.build == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set image variables | |
| id: vars | |
| run: | | |
| OWNER_LOWER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]') | |
| REGISTRY_IMAGE="ghcr.io/${OWNER_LOWER}/${{ env.IMAGE_NAME }}" | |
| echo "registry_image=${REGISTRY_IMAGE}" >> $GITHUB_OUTPUT | |
| - name: Free up disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| docker system prune -af | |
| df -h | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image to GHCR | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./modeling/transformers/Dockerfile | |
| tags: | | |
| ${{ steps.vars.outputs.registry_image }}:${{ needs.config.outputs.image_tag }} | |
| ${{ steps.vars.outputs.registry_image }}:${{ github.sha }} | |
| push: true | |
| cache-from: | | |
| type=gha | |
| type=registry,ref=${{ steps.vars.outputs.registry_image }}:latest | |
| type=registry,ref=${{ steps.vars.outputs.registry_image }}:${{ needs.config.outputs.image_tag }} | |
| cache-to: type=gha,mode=max | |
| test-ops: | |
| name: test-ops | |
| needs: [config, build] | |
| if: | | |
| always() && | |
| needs.config.outputs.run_ops == 'true' && | |
| (needs.build.result == 'success' || needs.build.result == 'skipped') | |
| runs-on: linux-amd64-gpu-rtxpro6000-latest-1 | |
| steps: | |
| - name: Create test results directory | |
| run: mkdir -p ${{ github.workspace }}/test-results | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull and run ops tests | |
| run: | | |
| OWNER_LOWER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]') | |
| IMAGE="ghcr.io/${OWNER_LOWER}/${{ env.IMAGE_NAME }}:${{ needs.config.outputs.image_tag }}" | |
| docker pull ${IMAGE} | |
| docker run --rm \ | |
| --gpus all \ | |
| -v ${{ github.workspace }}/test-results:/test-results \ | |
| -w /workspace/tilegym \ | |
| ${IMAGE} \ | |
| pytest -s tests/ops -v -k test_op \ | |
| -n auto \ | |
| --junitxml=/test-results/ops-results.xml \ | |
| --html=/test-results/ops-report.html \ | |
| --self-contained-html | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ops-test-results | |
| path: test-results/ops-* | |
| retention-days: 30 | |
| - name: Publish test results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: test-results/ops-results.xml | |
| check_name: Ops Test Results | |
| test-benchmark: | |
| name: test-benchmark | |
| needs: [config, build] | |
| if: | | |
| always() && | |
| needs.config.outputs.run_benchmark == 'true' && | |
| (needs.build.result == 'success' || needs.build.result == 'skipped') | |
| runs-on: linux-amd64-gpu-rtxpro6000-latest-1 | |
| steps: | |
| - name: Create test results directory | |
| run: mkdir -p ${{ github.workspace }}/test-results | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull and run benchmarks | |
| run: | | |
| OWNER_LOWER=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]') | |
| IMAGE="ghcr.io/${OWNER_LOWER}/${{ env.IMAGE_NAME }}:${{ needs.config.outputs.image_tag }}" | |
| docker pull ${IMAGE} | |
| docker run --rm \ | |
| --gpus all \ | |
| -v ${{ github.workspace }}/test-results:/test-results \ | |
| -w /workspace/tilegym/tests/benchmark \ | |
| ${IMAGE} \ | |
| ./run_all.sh --parallel --junit-xml /test-results/benchmark-results.xml | |
| - name: Upload benchmark results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-test-results | |
| path: test-results/benchmark-* | |
| retention-days: 30 | |
| - name: Publish benchmark results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: test-results/benchmark-results.xml | |
| check_name: Benchmark Test Results |