|
8 | 8 | - alpha
|
9 | 9 | - development
|
10 | 10 |
|
| 11 | +permissions: |
| 12 | + issues: write |
| 13 | + pull-requests: write |
| 14 | + |
11 | 15 | jobs:
|
12 | 16 | app-unit-tests:
|
13 | 17 | runs-on: ubuntu-latest
|
14 | 18 |
|
15 | 19 | steps:
|
16 | 20 | - name: Checkout code
|
17 |
| - uses: actions/checkout@v2 |
| 21 | + uses: actions/checkout@v4 |
18 | 22 |
|
19 |
| - - name: Set up Rust |
20 |
| - uses: actions-rs/toolchain@v1 |
21 |
| - with: |
22 |
| - toolchain: stable |
| 23 | + - name: Run cargo fmt --check |
| 24 | + id: fmt |
| 25 | + working-directory: ./clearing-house-app |
| 26 | + continue-on-error: true |
| 27 | + run: | |
| 28 | + set +e |
23 | 29 |
|
24 |
| - - name: Build and Test |
| 30 | + cargo fmt --check --message-format human >> cargo_fmt_output.txt |
| 31 | + exit_code=$? |
| 32 | +
|
| 33 | + echo "code=$exit_code" >> $GITHUB_OUTPUT |
| 34 | + echo "text<<EOF" >> $GITHUB_OUTPUT |
| 35 | + cat cargo_fmt_output.txt >> $GITHUB_OUTPUT |
| 36 | + echo "EOF" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + - name: Build |
| 39 | + id: build |
| 40 | + working-directory: ./clearing-house-app |
| 41 | + continue-on-error: false |
25 | 42 | run: |
|
26 |
| - cd clearing-house-app |
27 | 43 | cargo build
|
28 |
| - cargo test |
| 44 | +
|
| 45 | + - name: Test |
| 46 | + id: test |
| 47 | + working-directory: ./clearing-house-app |
| 48 | + continue-on-error: false |
| 49 | + env: |
| 50 | + NO_COLOR: true |
| 51 | + run: | |
| 52 | + set +e |
| 53 | +
|
| 54 | + cargo test &>> cargo_test_output.txt |
| 55 | + exit_code=$? |
| 56 | +
|
| 57 | + echo "code=$exit_code" >> $GITHUB_OUTPUT |
| 58 | + echo "text<<EOF" >> $GITHUB_OUTPUT |
| 59 | + cat cargo_test_output.txt >> $GITHUB_OUTPUT |
| 60 | + echo "EOF" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: Run cargo clippy |
| 63 | + id: clippy |
| 64 | + working-directory: ./clearing-house-app |
| 65 | + continue-on-error: true |
| 66 | + run: | |
| 67 | + set +e |
| 68 | +
|
| 69 | + cargo clippy >> cargo_clippy_output.txt |
| 70 | + exit_code=$? |
| 71 | + |
| 72 | + echo "code=$exit_code" >> $GITHUB_OUTPUT |
| 73 | + echo "text<<EOF" >> $GITHUB_OUTPUT |
| 74 | + cat cargo_clippy_output.txt >> $GITHUB_OUTPUT |
| 75 | + echo "EOF" >> $GITHUB_OUTPUT |
| 76 | +
|
| 77 | + - name: Post results to PR |
| 78 | + uses: actions/github-script@v7 |
| 79 | + if: always() |
| 80 | + env: |
| 81 | + FMT_OUTPUT: ${{ steps.fmt.outputs.text }} |
| 82 | + TEST_OUTPUT: ${{ steps.test.outputs.text }} |
| 83 | + LINTER_OUTPUT: ${{ steps.linter.outputs.text }} |
| 84 | + with: |
| 85 | + script: | |
| 86 | + const fmtOutput = process.env.FMT_OUTPUT; |
| 87 | + let fmtComment = `\`\`\` |
| 88 | + ${ fmtOutput } |
| 89 | + \`\`\``; |
| 90 | +
|
| 91 | + if (fmtComment == "```\n\n```") { |
| 92 | + fmtComment = "_No formatter warnings_"; |
| 93 | + } |
| 94 | +
|
| 95 | + const clippyOutput = process.env.LINTER_OUTPUT; |
| 96 | + let linterComment = `\`\`\` |
| 97 | + ${ clippyOutput } |
| 98 | + \`\`\``; |
| 99 | +
|
| 100 | + if (linterComment == "```\n\n```") { |
| 101 | + linterComment = "_No linter warnings_"; |
| 102 | + } |
| 103 | +
|
| 104 | + const testOutput = process.env.TEST_OUTPUT; |
| 105 | + let testComment = `<details><summary>Test log:</summary> |
| 106 | +
|
| 107 | + \`\`\` |
| 108 | + ${ testOutput } |
| 109 | + \`\`\` |
| 110 | +
|
| 111 | + </details>`; |
| 112 | +
|
| 113 | + if (testComment.length <= 59) { |
| 114 | + testComment = "_No test output_"; |
| 115 | + } |
| 116 | +
|
| 117 | + const body = `# Clearinghouse App Build report |
| 118 | + ## Formatter report ("cargo fmt --check"): |
| 119 | +
|
| 120 | + Exit code: ${{ steps.fmt.outputs.code }} |
| 121 | +
|
| 122 | + ${fmtComment} |
| 123 | +
|
| 124 | + ## Linter report ("cargo clippy"): |
| 125 | +
|
| 126 | + Exit code: ${{ steps.clippy.outputs.code }} |
| 127 | + |
| 128 | + ${linterComment} |
| 129 | +
|
| 130 | + ## Test log |
| 131 | + Exit code: ${{ steps.test.outputs.code }} |
| 132 | +
|
| 133 | + ${testComment} |
| 134 | + `; |
| 135 | +
|
| 136 | + github.rest.issues.createComment({ |
| 137 | + issue_number: context.issue.number, |
| 138 | + owner: context.repo.owner, |
| 139 | + repo: context.repo.repo, |
| 140 | + body: body |
| 141 | + }); |
29 | 142 |
|
30 | 143 | edc-unit-tests:
|
31 | 144 | runs-on: ubuntu-latest
|
|
0 commit comments