|
| 1 | +name: Upstream |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 1 * * *" |
| 6 | + push: |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + check: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: github.event_name == 'push' || github.event_name == 'pull_request' |
| 14 | + outputs: |
| 15 | + test-upstream: ${{ steps.detect-trigger.outputs.trigger-found }} |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: 2 |
| 20 | + - uses: xarray-contrib/ci-trigger@v1 |
| 21 | + id: detect-trigger |
| 22 | + with: |
| 23 | + keyword: "test-upstream" |
| 24 | + |
| 25 | + build: |
| 26 | + needs: check |
| 27 | + runs-on: ubuntu-latest |
| 28 | + if: | |
| 29 | + always() |
| 30 | + && ( |
| 31 | + needs.check.outputs.test-upstream == 'true' |
| 32 | + || (github.repository == 'dask/dask-ml' && github.event_name != 'pull_request') |
| 33 | + ) |
| 34 | +
|
| 35 | + env: |
| 36 | + COVERAGE: "true" |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout source |
| 40 | + uses: actions/checkout@v2 |
| 41 | + |
| 42 | + - name: Setup Conda Environment |
| 43 | + uses: conda-incubator/setup-miniconda@v2 |
| 44 | + with: |
| 45 | + miniforge-variant: Mambaforge |
| 46 | + miniforge-version: latest |
| 47 | + use-mamba: true |
| 48 | + channel-priority: strict |
| 49 | + python-version: "3.9" |
| 50 | + environment-file: ci/environment-3.9.yaml |
| 51 | + activate-environment: test-environment |
| 52 | + auto-activate-base: false |
| 53 | + |
| 54 | + - name: Install |
| 55 | + shell: bash -l {0} |
| 56 | + env: |
| 57 | + UPSTREAM_DEV: 1 |
| 58 | + run: source ci/install.sh |
| 59 | + |
| 60 | + - name: Run tests |
| 61 | + shell: bash -l {0} |
| 62 | + run: pytest -v |
| 63 | + |
| 64 | + report: |
| 65 | + name: report |
| 66 | + needs: build |
| 67 | + if: | |
| 68 | + always() |
| 69 | + && github.event_name != 'pull_request' |
| 70 | + && github.repository == 'dask/dask-ml' |
| 71 | + && needs.build.result == 'failure' |
| 72 | + runs-on: ubuntu-latest |
| 73 | + defaults: |
| 74 | + run: |
| 75 | + shell: bash |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v2 |
| 78 | + - name: Report failures |
| 79 | + uses: actions/github-script@v3 |
| 80 | + with: |
| 81 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + script: | |
| 83 | + const title = "⚠️ Upstream CI failed ⚠️" |
| 84 | + const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}` |
| 85 | + const issue_body = `[Workflow Run URL](${workflow_url})` |
| 86 | + // Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures |
| 87 | + const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){ |
| 88 | + repository(owner: $owner, name: $name) { |
| 89 | + issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) { |
| 90 | + edges { |
| 91 | + node { |
| 92 | + body |
| 93 | + id |
| 94 | + number |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + }`; |
| 100 | + const variables = { |
| 101 | + owner: context.repo.owner, |
| 102 | + name: context.repo.repo, |
| 103 | + label: 'upstream', |
| 104 | + creator: "github-actions[bot]" |
| 105 | + } |
| 106 | + const result = await github.graphql(query, variables) |
| 107 | + // If no issue is open, create a new issue, |
| 108 | + // else update the body of the existing issue. |
| 109 | + if (result.repository.issues.edges.length === 0) { |
| 110 | + github.issues.create({ |
| 111 | + owner: variables.owner, |
| 112 | + repo: variables.name, |
| 113 | + body: issue_body, |
| 114 | + title: title, |
| 115 | + labels: [variables.label] |
| 116 | + }) |
| 117 | + } else { |
| 118 | + github.issues.update({ |
| 119 | + owner: variables.owner, |
| 120 | + repo: variables.name, |
| 121 | + issue_number: result.repository.issues.edges[0].node.number, |
| 122 | + body: issue_body |
| 123 | + }) |
| 124 | + } |
0 commit comments