-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Safe commenting on PRs #1729
Changes from 8 commits
b877c3d
4742a5a
280c275
62c387b
8bfde5c
e34558d
b8fa934
340b6e6
9e99639
9143426
6bbc877
25e5b53
08343e4
c02d67f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: 'Export data for PR comment' | ||
description: 'Exports the neccessary data to post a PR comment securely.' | ||
|
||
# This action might be running off of a fork and would thus not have write | ||
# permissions on the origin repository. In order to allow a separate | ||
# priviledged action to post a comment on a pull request, upload the | ||
# necessary metadata. | ||
|
||
inputs: | ||
name: | ||
description: 'A unique name for the artifact used for exporting.' | ||
required: true | ||
contents: | ||
description: 'A filename with a comment (in Markdown) to be added to the PR.' | ||
required: true | ||
log-url: | ||
description: 'A URL to a log to be linked from the PR comment.' | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- if: github.event_name == 'pull_request' | ||
shell: bash | ||
run: | | ||
mkdir comment-data | ||
cp "${{ inputs.contents }}" comment-data/contents | ||
echo "${{ inputs.name }}" > comment-data/name | ||
echo "${{ inputs.log-url }}" > comment-data/log-url | ||
echo "${{ github.event.number }}" > comment-data/pr-number | ||
|
||
- if: github.event_name == 'pull_request' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ inputs.name }} | ||
path: comment-data | ||
retention-days: 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: 'Comment on PR' | ||
description: 'Post a PR comment securely.' | ||
|
||
inputs: | ||
name: | ||
description: 'Artifact name to import comment data from.' | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
run-id: ${{ github.event.workflow_run.id }} | ||
name: ${{ inputs.name }} | ||
|
||
- id: pr-number | ||
shell: bash | ||
run: echo "number=$(cat pr-number)" >> "$GITHUB_OUTPUT" | ||
|
||
- shell: bash | ||
run: | | ||
[ -s log-url ] && echo "" >> contents && echo "[:arrow_down: Download logs]($(cat log-url))" >> contents | ||
|
||
- uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
filePath: contents | ||
pr_number: ${{ steps.pr-number.outputs.number }} | ||
comment_tag: ${{ inputs.name }}-comment |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Post test results as pull request comment. | ||
# | ||
# This is done as a separate workflow as it requires write permissions. The | ||
# tests itself might run off of a fork, i.e. an untrusted environment and should | ||
# thus not be granted write permissions. | ||
|
||
name: Benchmark Comment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Bench"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
comment: | ||
permissions: | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
if: github.event.workflow_run.event == 'pull_request' | ||
steps: | ||
- uses: ./.github/actions/pr-comment | ||
with: | ||
name: bench |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,8 +72,8 @@ jobs: | |
- name: Use MSYS2 environment and install more dependencies (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
echo "C:\\msys64\\usr\\bin" >> "$GITHUB_PATH" | ||
echo "C:\\msys64\\mingw64\\bin" >> "$GITHUB_PATH" | ||
printf "C:\\msys64\\usr\\bin" >> "$GITHUB_PATH" | ||
printf "C:\\msys64\\mingw64\\bin" >> "$GITHUB_PATH" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When should we be using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was because of a |
||
/c/msys64/usr/bin/pacman -S --noconfirm nsinstall | ||
python3 -m pip install git+https://github.com/nodejs/gyp-next | ||
echo "$(python3 -m site --user-base)/bin" >> "$GITHUB_PATH" | ||
|
@@ -85,9 +85,11 @@ jobs: | |
- name: Set up NSS/NSPR build environment (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
echo "GYP_MSVS_OVERRIDE_PATH=$VSINSTALLDIR" >> "$GITHUB_ENV" | ||
echo "GYP_MSVS_VERSION=2022" >> "$GITHUB_ENV" | ||
echo "BASH=$SHELL" >> "$GITHUB_ENV" | ||
{ | ||
echo "GYP_MSVS_OVERRIDE_PATH=$VSINSTALLDIR" | ||
echo "GYP_MSVS_VERSION=2022" | ||
echo "BASH=$SHELL" | ||
} >> "$GITHUB_ENV" | ||
# See https://github.com/ilammy/msvc-dev-cmd#name-conflicts-with-shell-bash | ||
rm /usr/bin/link.exe | ||
|
||
|
@@ -101,19 +103,23 @@ jobs: | |
uses: ./.github/actions/nss | ||
|
||
- name: Build | ||
run: cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --all-targets --features ci | ||
run: | | ||
# shellcheck disable=SC2086 | ||
cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --all-targets --features ci | ||
|
||
- name: Run tests and determine coverage | ||
run: | | ||
# shellcheck disable=SC2086 | ||
cargo +${{ matrix.rust-toolchain }} llvm-cov nextest $BUILD_TYPE --all-targets --features ci --no-fail-fast --lcov --output-path lcov.info | ||
cargo +${{ matrix.rust-toolchain }} bench --features bench --no-run | ||
|
||
- name: Run client/server transfer | ||
run: | | ||
# shellcheck disable=SC2086 | ||
cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --bin neqo-client --bin neqo-server | ||
target/$BUILD_DIR/neqo-server $HOST:4433 & | ||
"target/$BUILD_DIR/neqo-server" "$HOST:4433" & | ||
PID=$! | ||
target/$BUILD_DIR/neqo-client --output-dir . https://$HOST:4433/$SIZE | ||
"target/$BUILD_DIR/neqo-client" --output-dir . "https://$HOST:4433/$SIZE" | ||
kill $PID | ||
[ "$(wc -c <"$SIZE")" -eq "$SIZE" ] || exit 1 | ||
env: | ||
|
@@ -127,7 +133,7 @@ jobs: | |
if [ "${{ matrix.rust-toolchain }}" != "nightly" ]; then | ||
CONFIG_PATH="--config-path=$(mktemp)" | ||
fi | ||
cargo +${{ matrix.rust-toolchain }} fmt --all -- --check $CONFIG_PATH | ||
cargo +${{ matrix.rust-toolchain }} fmt --all -- --check "$CONFIG_PATH" | ||
if: success() || failure() | ||
|
||
- name: Clippy | ||
|
@@ -152,10 +158,3 @@ jobs: | |
fail_ci_if_error: false | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable' | ||
|
||
bench: | ||
name: "Benchmark" | ||
needs: [check] | ||
permissions: | ||
pull-requests: write | ||
uses: ./.github/workflows/bench.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,40 +17,8 @@ jobs: | |
permissions: | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'failure' | ||
if: github.event.workflow_run.event == 'pull_request' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case of qns, the comment should still only be printed on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this needs to be restored - I was just trying to make it generate any output. |
||
steps: | ||
- name: Download comment-data | ||
uses: actions/download-artifact@v4 | ||
- uses: ./.github/actions/pr-comment | ||
with: | ||
run-id: ${{ github.event.workflow_run.id }} | ||
name: comment-data | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Format GitHub comment | ||
run: | | ||
pwd | ||
ls -la | ||
echo '[**QUIC Interop Runner**](https://github.com/quic-interop/quic-interop-runner)' >> comment | ||
echo '' >> comment | ||
echo '```' >> comment | ||
cat summary >> comment | ||
echo '```' >> comment | ||
echo '' >> comment | ||
echo 'Download artifacts [here](' >> comment | ||
cat logs-url >> comment | ||
echo ').' >> comment | ||
shell: bash | ||
|
||
- name: Read PR Number | ||
id: pr-number | ||
run: echo "::set-output name=number::$(cat pr-number)" | ||
shell: bash | ||
|
||
- name: Comment PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
filePath: comment | ||
pr_number: ${{ steps.pr-number.outputs.number }} | ||
comment_tag: quic-network-simulator-comment | ||
name: qns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each step in
pr-comment-data-export
has thisif
already. Can we remove it either here or in the action?