chore: implement tcp #64
Workflow file for this run
This file contains 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: Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
env: | |
CI: 1 | |
CARGO_INCREMENTAL: 0 | |
CARGO_TERM_COLOR: 'always' | |
DIFF: 0 | |
# For faster CI | |
RUST_LOG: 'off' | |
jobs: | |
cargo-fmt: | |
name: Cargo fmt | |
runs-on: ubuntu-latest | |
env: | |
RUST_LOG: '0' | |
steps: | |
- name: Find PR Comment | |
id: comment | |
if: github.event_name == 'pull_request' | |
uses: peter-evans/find-comment@v2 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: '<!-- CI COMMENT -->' | |
- name: Create or update PR comment | |
if: github.event_name == 'pull_request' && steps.comment.outputs.comment-id != '' | |
uses: peter-evans/create-or-update-comment@v2 | |
continue-on-error: true | |
with: | |
comment-id: ${{ steps.comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
## :hourglass_flowing_sand: CI is running again... :hourglass_flowing_sand: | |
[Wait for it...](https://github.com/Sofi-Tech/Rust-Workers/actions/runs/${{ github.run_id }}) | |
<!-- CI COMMENT --> | |
edit-mode: replace | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
components: rustfmt | |
- run: cargo fmt --all -- --check | |
cargo-clippy: | |
name: Cargo clippy | |
if: >- | |
${{ !contains(github.event.head_commit.message, 'chore: ') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
components: clippy | |
- run: cargo clippy --all --all-targets -- -D warnings | |
cargo-test: | |
name: Cargo test | |
if: >- | |
${{ !contains(github.event.head_commit.message, 'chore: ') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
- name: Rust tests | |
run: cargo test --tests -- -Zunstable-options --report-time | tee test.txt | |
- name: Upload test.txt file to artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-report | |
path: | | |
test.txt | |
# drop.png | |
if-no-files-found: error | |
# Above test down't exits if test fails because we are writing it in a file. | |
# So checking the file again to see if it was failed | |
- name: Fail if test fails | |
if: always() | |
run: | | |
if grep -q "test result: FAILED" test.txt || grep -q "due to previous error" test.txt; then | |
exit 1 | |
fi | |
final: | |
name: Ok | |
needs: | |
- cargo-fmt | |
- cargo-clippy | |
- cargo-test | |
if: always() | |
permissions: | |
contents: read | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check cancellation | |
id: cancelled | |
if: needs.cargo-fmt.result == 'cancelled' || needs.cargo-clippy.result == 'cancelled' || needs.cargo-test.result == 'cancelled' | |
run: echo "cancelled=true" >> $GITHUB_OUTPUT | |
- name: Start summary | |
run: | | |
echo "The following steps have failed in CI" > comment.md | |
echo >> comment.md | |
- name: Cargo Format | |
if: always() && needs.cargo-fmt.result != 'success' && needs.cargo-fmt.result != 'skipped' | |
run: | | |
echo "- Cargo Format" >> failures.md | |
exit 1 | |
- name: Cargo Clippy | |
if: always() && needs.cargo-clippy.result != 'success' && needs.cargo-clippy.result != 'skipped' | |
run: | | |
echo "- Cargo Clippy" >> failures.md | |
exit 1 | |
- name: Cargo Test | |
if: always() && needs.cargo-test.result != 'success' && needs.cargo-test.result != 'skipped' | |
run: | | |
echo "- Cargo Test" >> failures.md | |
exit 1 | |
- name: Add failure prose text | |
if: failure() | |
run: | | |
echo "## :warning: CI failed :warning:" > comment.md | |
echo >> comment.md | |
echo "The following steps have failed in CI:" >> comment.md | |
echo >> comment.md | |
cat failures.md >> comment.md | |
echo >> comment.md | |
echo "See [workflow summary](https://github.com/Sofi-Tech/Rust-Workers/actions/runs/${{ github.run_id }}) for details">> comment.md | |
echo >> comment.md | |
echo "<!-- CI COMMENT -->" >> comment.md | |
- name: Add success prose text | |
if: success() | |
run: | | |
echo "## :green_circle: CI successful :green_circle:" > comment.md | |
echo >> comment.md | |
echo "Thanks" >> comment.md | |
echo >> comment.md | |
echo "<!-- CI COMMENT -->" >> comment.md | |
- name: Download test.txt file from artifacts | |
if: always() && github.event_name == 'pull_request' && steps.cancelled.outputs.cancelled != 'true' | |
uses: actions/download-artifact@v3 | |
with: | |
name: test-report | |
path: report/ | |
- name: Add Test Report | |
if: always() && github.event_name == 'pull_request' && steps.cancelled.outputs.cancelled != 'true' | |
run: | | |
echo "<details>" >> comment.md | |
echo "<summary>Test Report</summary>" >> comment.md | |
cat report/test.txt >> comment.md | |
echo "</details>" >> comment.md | |
# Sending image isn't possible atm | |
# Sending buffer exits the body limit | |
# echo >> comment.md | |
# echo "<details>" >> comment.md | |
# echo "<summary>Drop.png</summary>" >> comment.md | |
# echo "<img src=\"data:image/png;base64," >> comment.md | |
# base64 report/drop.png >> comment.md | |
# echo "\"/>" >> comment.md | |
# echo "</details>" >> comment.md | |
- name: Find PR Comment | |
id: comment | |
if: always() && github.event_name == 'pull_request' && steps.cancelled.outputs.cancelled != 'true' | |
uses: peter-evans/find-comment@v2 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: '<!-- CI COMMENT -->' | |
- name: Create or update PR comment | |
if: always() && github.event_name == 'pull_request' && steps.cancelled.outputs.cancelled != 'true' | |
uses: peter-evans/create-or-update-comment@v2 | |
continue-on-error: true | |
with: | |
comment-id: ${{ steps.comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body-file: 'comment.md' | |
edit-mode: replace | |
- name: It's not fine | |
if: failure() && steps.cancelled.outputs.cancelled != 'true' | |
run: exit 1 | |
- name: It's fine | |
if: success() && steps.cancelled.outputs.cancelled != 'true' | |
run: echo Ok |