|
| 1 | +name: Test PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +defaults: |
| 7 | + run: |
| 8 | + shell: 'bash -Eeuo pipefail -x {0}' |
| 9 | + |
| 10 | +jobs: |
| 11 | + |
| 12 | + naughty: |
| 13 | + name: Naughty |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + - name: Check for Common Issues |
| 18 | + run: | |
| 19 | + git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew |
| 20 | + ~/bashbrew/bashbrew.sh --version > /dev/null |
| 21 | + export PATH="$HOME/bashbrew/bin:$PATH" |
| 22 | + bashbrew --version |
| 23 | + .github/workflows/naughty.sh |
| 24 | +
|
| 25 | + label: |
| 26 | + name: Label |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v2 |
| 30 | + - id: labels |
| 31 | + name: Generate List |
| 32 | + run: | |
| 33 | + labels="$(.github/workflows/pr-labels.sh)" |
| 34 | + labels="$(jq -Rsc 'rtrimstr("\n") | split("\n") | { labels: ., count: length }' <<<"$labels")" |
| 35 | + jq . <<<"$labels" |
| 36 | + echo "::set-output name=labels::$labels" |
| 37 | + - name: Apply Labels |
| 38 | + uses: actions/github-script@0.9.0 |
| 39 | + with: |
| 40 | + script: | |
| 41 | + const data = ${{ steps.labels.outputs.labels }} |
| 42 | + github.issues.addLabels({ |
| 43 | + owner: context.repo.owner, |
| 44 | + repo: context.repo.repo, |
| 45 | + issue_number: context.payload.pull_request.number, |
| 46 | + labels: data.labels, |
| 47 | + }) |
| 48 | + if: fromJSON(steps.labels.outputs.labels).count > 0 |
| 49 | + |
| 50 | + diff: |
| 51 | + name: Diff |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v2 |
| 55 | + - id: diff |
| 56 | + name: Run ./diff-pr.sh |
| 57 | + run: | |
| 58 | + git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew |
| 59 | + ~/bashbrew/bashbrew.sh --version > /dev/null |
| 60 | + export PATH="$HOME/bashbrew/bin:$PATH" |
| 61 | + bashbrew --version |
| 62 | + diff="$(./diff-pr.sh 0)" |
| 63 | + # "Body is too long (maximum is 65536 characters)" (so we'll check for some fudge room and pre-filter the diff) |
| 64 | + # TODO consider instead creating a Gist (although that requires a separate type of token, so much less interesting) |
| 65 | + diff="$(jq -Rcs 'rtrimstr("\n") | { diff: (if length < 65000 then . else "TODO diff too large for GitHub comment!\nSee: http://github.com/" + env.GITHUB_REPOSITORY + "/actions/runs/" + env.GITHUB_RUN_ID end), length: length }' <<<"$diff")" |
| 66 | + echo "::set-output name=diff::$diff" |
| 67 | + - name: Delete Old Comments |
| 68 | + uses: actions/github-script@0.9.0 |
| 69 | + with: |
| 70 | + script: | |
| 71 | + const { data: comments } = await github.issues.listComments({ |
| 72 | + owner: context.repo.owner, |
| 73 | + repo: context.repo.repo, |
| 74 | + issue_number: context.payload.pull_request.number, |
| 75 | + }) |
| 76 | + comments.forEach((comment) => { |
| 77 | + if (comment.user.login === 'github-actions[bot]') { |
| 78 | + github.issues.deleteComment({ |
| 79 | + owner: context.repo.owner, |
| 80 | + repo: context.repo.repo, |
| 81 | + comment_id: comment.id, |
| 82 | + }) |
| 83 | + } |
| 84 | + }) |
| 85 | + - name: Create Diff Comment |
| 86 | + uses: actions/github-script@0.9.0 |
| 87 | + with: |
| 88 | + script: | |
| 89 | + const data = ${{ steps.diff.outputs.diff }} |
| 90 | + const body = "<details>\n<summary>Diff for " + context.payload.pull_request.head.sha + ":</summary>\n\n```diff\n" + data.diff + "\n```\n\n</details>" |
| 91 | + github.issues.createComment({ |
| 92 | + owner: context.repo.owner, |
| 93 | + repo: context.repo.repo, |
| 94 | + issue_number: context.payload.pull_request.number, |
| 95 | + body: body, |
| 96 | + }) |
| 97 | + if: fromJSON(steps.diff.outputs.diff).length > 0 |
| 98 | + |
| 99 | + generate-jobs: |
| 100 | + name: Generate Jobs |
| 101 | + runs-on: ubuntu-latest |
| 102 | + outputs: |
| 103 | + strategy: ${{ steps.generate-jobs.outputs.strategy }} |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v2 |
| 106 | + - id: generate-jobs |
| 107 | + name: Generate Jobs |
| 108 | + run: | |
| 109 | + git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew |
| 110 | + strategy="$(.github/workflows/generate.sh ~/bashbrew)" |
| 111 | + jq . <<<"$strategy" # sanity check / debugging aid |
| 112 | + echo "::set-output name=strategy::$strategy" |
| 113 | +
|
| 114 | + test: |
| 115 | + needs: generate-jobs |
| 116 | + strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} |
| 117 | + name: ${{ matrix.name }} |
| 118 | + runs-on: ${{ matrix.os }} |
| 119 | + steps: |
| 120 | + - uses: actions/checkout@v2 |
| 121 | + - name: Prepare Environment |
| 122 | + run: ${{ matrix.runs.prepare }} |
| 123 | + - name: Pull Dependencies |
| 124 | + run: ${{ matrix.runs.pull }} |
| 125 | + - name: Build ${{ matrix.name }} |
| 126 | + run: ${{ matrix.runs.build }} |
| 127 | + - name: History ${{ matrix.name }} |
| 128 | + run: ${{ matrix.runs.history }} |
| 129 | + - name: Test ${{ matrix.name }} |
| 130 | + run: ${{ matrix.runs.test }} |
| 131 | + - name: '"docker images"' |
| 132 | + run: ${{ matrix.runs.images }} |
0 commit comments