|
| 1 | +name: CI - with Numpy/Scipy nightly wheels (nightly) |
| 2 | +# This configures a github action that runs the JAX test suite against nightly development builds |
| 3 | +# of numpy and scipy, in order to catch issues with new package versions prior to their release. |
| 4 | +# Unlike our other CI, this is one that we expect to fail frequently, and so we don't run it against |
| 5 | +# every commit and PR in the repository. Rather, we run it on a schedule, and failures lead to an |
| 6 | +# issue being created or updated. |
| 7 | +# Portions of this adapted from https://github.com/pydata/xarray/blob/main/.github/workflows/upstream-dev-ci.yaml |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +on: |
| 14 | + schedule: |
| 15 | + - cron: "0 12 * * *" # Daily at 12:00 UTC |
| 16 | + workflow_dispatch: # allows triggering the workflow run manually |
| 17 | + pull_request: # Automatically trigger on pull requests affecting this file |
| 18 | + branches: |
| 19 | + - main |
| 20 | + paths: |
| 21 | + - '**workflows/upstream-nightly.yml' |
| 22 | + |
| 23 | +jobs: |
| 24 | + upstream-dev: |
| 25 | + runs-on: ubuntu-20.04-16core |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + checks: write # for upload-artifact |
| 29 | + defaults: |
| 30 | + run: |
| 31 | + shell: bash -l {0} |
| 32 | + strategy: |
| 33 | + fail-fast: false |
| 34 | + matrix: |
| 35 | + python-version: ["3.12"] |
| 36 | + outputs: |
| 37 | + artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }} |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4 |
| 40 | + - name: Set up Python ${{ matrix.python-version }} |
| 41 | + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # ratchet:actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: ${{ matrix.python-version }} |
| 44 | + - name: Install JAX test requirements |
| 45 | + run: | |
| 46 | + pip install -r build/test-requirements.txt |
| 47 | + pip install pytest-reportlog |
| 48 | + - name: Install numpy & scipy development versions |
| 49 | + run: | |
| 50 | + pip install \ |
| 51 | + -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ |
| 52 | + --no-deps \ |
| 53 | + --pre \ |
| 54 | + --upgrade \ |
| 55 | + numpy \ |
| 56 | + scipy |
| 57 | + - name: Install JAX |
| 58 | + run: | |
| 59 | + pip install .[ci] |
| 60 | + - name: Run tests |
| 61 | + if: success() |
| 62 | + id: status |
| 63 | + env: |
| 64 | + JAX_NUM_GENERATED_CASES: 1 |
| 65 | + JAX_ENABLE_X64: true |
| 66 | + JAX_ENABLE_CHECKS: true |
| 67 | + JAX_SKIP_SLOW_TESTS: true |
| 68 | + PY_COLORS: 1 |
| 69 | + run: | |
| 70 | + echo "JAX_NUM_GENERATED_CASES=$JAX_NUM_GENERATED_CASES" |
| 71 | + echo "JAX_ENABLE_X64=$JAX_ENABLE_X64" |
| 72 | + echo "JAX_ENABLE_CHECKS=$JAX_ENABLE_CHECKS" |
| 73 | + echo "JAX_SKIP_SLOW_TESTS=$JAX_SKIP_SLOW_TESTS" |
| 74 | + pytest -n auto --tb=short -rf --maxfail=20 \ |
| 75 | + --report-log output-${{ matrix.python-version }}-log.jsonl \ |
| 76 | + tests \ |
| 77 | + || ( |
| 78 | + echo 'ARTIFACTS_AVAILABLE=true' >> $GITHUB_OUTPUT && false |
| 79 | + ) |
| 80 | + - name: Upload artifacts |
| 81 | + if: | |
| 82 | + failure() |
| 83 | + && steps.status.outcome == 'failure' |
| 84 | + && github.event_name == 'schedule' |
| 85 | + && github.repository == 'google/jax' |
| 86 | + uses: actions/upload-artifact@v3 |
| 87 | + with: |
| 88 | + name: output-${{ matrix.python-version }}-log.jsonl |
| 89 | + path: output-${{ matrix.python-version }}-log.jsonl |
| 90 | + retention-days: 5 |
| 91 | + |
| 92 | + report: |
| 93 | + name: report |
| 94 | + needs: upstream-dev |
| 95 | + permissions: |
| 96 | + contents: read |
| 97 | + issues: write |
| 98 | + if: | |
| 99 | + failure() |
| 100 | + && github.event_name == 'schedule' |
| 101 | + && needs.upstream-dev.outputs.artifacts_availability == 'true' |
| 102 | + runs-on: ubuntu-latest |
| 103 | + defaults: |
| 104 | + run: |
| 105 | + shell: bash |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4 |
| 108 | + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # ratchet:actions/setup-python@v4 |
| 109 | + with: |
| 110 | + python-version: "3.x" |
| 111 | + - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # ratchet:actions/download-artifact@v4 |
| 112 | + with: |
| 113 | + path: /tmp/workspace/logs |
| 114 | + - name: install requirements |
| 115 | + run: | |
| 116 | + python -m pip install pytest |
| 117 | + - name: Move all log files into a single directory |
| 118 | + run: | |
| 119 | + rsync -a /tmp/workspace/logs/output-*/ ./logs |
| 120 | + ls -R ./logs |
| 121 | + cat logs/*.jsonl > pytest-logs.txt |
| 122 | + python .github/workflows/parse_logs.py pytest-logs.txt --outfile=parsed-logs.txt |
| 123 | + - name: Report failures |
| 124 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # ratchet:actions/github-script@v7 |
| 125 | + with: |
| 126 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + script: | |
| 128 | + const fs = require('fs'); |
| 129 | + const parsed_logs = fs.readFileSync('parsed-logs.txt', 'utf8'); |
| 130 | + const title = "⚠️ Nightly upstream-dev CI failed ⚠️" |
| 131 | + const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}` |
| 132 | + const issue_body = `[Workflow Run URL](${workflow_url})\n${parsed_logs}` |
| 133 | + // Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures |
| 134 | + const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){ |
| 135 | + repository(owner: $owner, name: $name) { |
| 136 | + issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) { |
| 137 | + edges { |
| 138 | + node { |
| 139 | + body |
| 140 | + id |
| 141 | + number |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + }`; |
| 147 | + const variables = { |
| 148 | + owner: context.repo.owner, |
| 149 | + name: context.repo.repo, |
| 150 | + label: 'CI', |
| 151 | + creator: "github-actions[bot]" |
| 152 | + } |
| 153 | + const result = await github.graphql(query, variables) |
| 154 | + // If no issue is open, create a new issue, |
| 155 | + // else update the body of the existing issue. |
| 156 | + if (result.repository.issues.edges.length === 0) { |
| 157 | + github.rest.issues.create({ |
| 158 | + owner: variables.owner, |
| 159 | + repo: variables.name, |
| 160 | + body: issue_body, |
| 161 | + title: title, |
| 162 | + labels: [variables.label] |
| 163 | + }) |
| 164 | + } else { |
| 165 | + github.rest.issues.update({ |
| 166 | + owner: variables.owner, |
| 167 | + repo: variables.name, |
| 168 | + issue_number: result.repository.issues.edges[0].node.number, |
| 169 | + body: issue_body |
| 170 | + }) |
| 171 | + } |
0 commit comments