Skip to content

Commit

Permalink
fix next-swc CI check (#5236)
Browse files Browse the repository at this point in the history
### Description

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
ForsakenHarmony authored Jun 8, 2023
1 parent 8f8a14c commit a00ba87
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,6 @@ jobs:
permissions:
pull-requests: write
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

Expand All @@ -630,29 +627,57 @@ jobs:
with:
repository: vercel/next.js

- name: Setup Rust
uses: ./.github/actions/setup-rust

- name: Build next-swc
continue-on-error: true
env:
CARGO_TERM_COLOR: never
run: |
export TURBOPACK_REMOTE="https://github.com/vercel/turbo"
# Apply patches to the cargo to the latest turbopack's sha.
export BINDING=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbo-binding" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
# patch the turbo git dependency with the commit of the current PR.
export BINDING=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbopack-binding" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
export TASKS=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbo-tasks" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
export TASKS_FS=$(printf 'patch."%s".%s.git="%s?rev=%s"' "$TURBOPACK_REMOTE" "turbo-tasks-fs" "$TURBOPACK_REMOTE" "$GITHUB_SHA")
cd packages/next-swc
cargo check --config $BINDING --config $TASKS --config $TASKS_FS --all -p next-swc-api -p next-dev --no-default-features --features cli,custom_allocator,rustls-tls,__internal_nextjs_integration_test --message-format short --quiet &> cargo_output.log
# set pipefail so the exit code of `cargo check` gets preserved
(set -o pipefail && \
cargo check \
--config $BINDING --config $TASKS --config $TASKS_FS \
--all -p next-swc-api -p next-dev \
--no-default-features --features cli,custom_allocator,rustls-tls,__internal_nextjs_integration_test \
--message-format short --quiet \
2>&1 | tee cargo_output.log)
- name: Success Log
run: |
printf ":white_check_mark: This change can build \`next-swc\`" > out.log
- name: Post logs if there are errors
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp packages/next-swc/cargo_output.log ./cargo_output.log
if grep 'error: could not compile' ./cargo_output.log; then (printf "This change may fail to build \`next-swc\`. \n\n\`\`\`\n"; cat ./cargo_output.log; printf "\`\`\`\n") > out.log; else printf ":white_check_mark: This change can build \`next-swc\`" > out.log; fi
job_url=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs --paginate --jq '.jobs.[] | select(.name == "Check next-swc").html_url')
# strip ansi colors with `sed`
echo "\
:warning: This change may fail to build \`next-swc\`.
<details><summary>Logs</summary>
<p>
\`\`\`
$(cat cargo_output.log | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g")
\`\`\`
</p>
</details>
See [job summary]($job_url) for details
" > out.log
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
if: github.repository == 'vercel/turbo'
if: always() && github.repository == 'vercel/turbo'
# We'll not block CI on this step
continue-on-error: true
with:
Expand Down Expand Up @@ -1346,8 +1371,7 @@ jobs:
# Upload Turbopack's test results into datadog.
upload_test_results:
name: Upload Test results
needs:
[determine_jobs, turbopack_rust_test1, turbopack_rust_test2]
needs: [determine_jobs, turbopack_rust_test1, turbopack_rust_test2]
# We have to set condition to always, since we want to upload test results for the failed tests as well.
if: ${{ always() }}
runs-on: ubuntu-latest
Expand Down

0 comments on commit a00ba87

Please sign in to comment.