| name: package:boring | |
| permissions: | |
| contents: read | |
| on: | |
| # Run on PRs and pushes to the default branch. | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - '.github/workflows/boring.yaml' | |
| - 'pkgs/boring/**' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - '.github/workflows/boring.yaml' | |
| - 'pkgs/boring/**' | |
| schedule: | |
| - cron: "0 0 * * 0" | |
| # Also runs the refresh job. | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| working-directory: pkgs/boring/ | |
| jobs: | |
| # Check code formatting and static analysis on a single OS (linux) | |
| # against Dart dev. | |
| analyze: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| sdk: [dev] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d | |
| with: | |
| sdk: ${{ matrix.sdk }} | |
| - id: install | |
| name: Install dependencies | |
| run: dart pub get | |
| - name: Check formatting | |
| run: dart format --output=none --set-exit-if-changed . | |
| if: always() && steps.install.outcome == 'success' | |
| - name: Analyze code | |
| run: dart analyze --fatal-infos | |
| if: always() && steps.install.outcome == 'success' | |
| # The `fetch` build mode downloads the libraries pinned in hashes.dart, | |
| # which boring_binaries.yaml builds from the native sources on main. A | |
| # release of package:boring mustn't ship libraries built from other | |
| # sources than the ones it vendors, so this fails once the version is no | |
| # longer a -wip one. | |
| - name: Check that the prebuilt libraries match the native sources | |
| run: ./tool/check_prebuilt_binaries.sh | |
| if: always() && steps.install.outcome == 'success' | |
| # Build BoringSSL from source with the build hook and run the tests on each | |
| # desktop OS (Linux, macOS, and Windows each use different linker flags in | |
| # hook/link.dart), including cross-compiling to linux-arm64 with and without | |
| # a cross-toolchain. | |
| test: | |
| needs: analyze | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| sdk: [stable] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d | |
| with: | |
| sdk: ${{ matrix.sdk }} | |
| - name: Setup NASM | |
| if: runner.os == 'Windows' | |
| uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b | |
| - name: Install Linux cross toolchain (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| # A third-party tap, which Homebrew can't pin, unlike the Windows download | |
| # below. It only links the test's cross-compiled example, never anything | |
| # that is released. | |
| - name: Install Linux cross toolchain (macOS) | |
| if: runner.os == 'macOS' | |
| run: brew install messense/macos-cross-toolchains/aarch64-unknown-linux-gnu | |
| - name: Install Linux cross toolchain (Windows) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| env: | |
| TOOLCHAIN_URL: https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-aarch64-none-linux-gnu.zip | |
| # From the .sha256asc file published next to the zip. | |
| TOOLCHAIN_SHA256: 9428b2039923916418ec7037025be8cec3202926d65db9452519977834ad2a89 | |
| run: | | |
| curl -fSL -o "$RUNNER_TEMP/arm-gnu-toolchain.zip" "$TOOLCHAIN_URL" | |
| actual="$(sha256sum < "$RUNNER_TEMP/arm-gnu-toolchain.zip" | cut -d' ' -f1)" | |
| if [ "$actual" != "$TOOLCHAIN_SHA256" ]; then | |
| echo "::error::Expected SHA-256 $TOOLCHAIN_SHA256 for $TOOLCHAIN_URL, got $actual." | |
| exit 1 | |
| fi | |
| 7z x "$RUNNER_TEMP/arm-gnu-toolchain.zip" -o"$RUNNER_TEMP/arm-gnu-toolchain" -y >/dev/null | |
| BIN_DIR="$RUNNER_TEMP/arm-gnu-toolchain/bin" | |
| for f in "$BIN_DIR"/aarch64-none-linux-gnu-*.exe; do | |
| cp "$f" "${f/aarch64-none-linux-gnu-/aarch64-linux-gnu-}" | |
| done | |
| cygpath -w "$BIN_DIR" >> "$GITHUB_PATH" | |
| - id: install | |
| name: Install dependencies | |
| run: dart pub get | |
| - name: Run tests | |
| run: dart test | |
| if: always() && steps.install.outcome == 'success' | |
| # Check the bundled BoringSSL and the bindings against Project Wycheproof. | |
| conformance: | |
| needs: analyze | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d | |
| with: | |
| sdk: stable | |
| - name: Install dependencies | |
| run: dart pub get | |
| - name: Run Wycheproof conformance tests | |
| run: ./tool/run_conformance_tests.sh | |
| # Check X.509 path validation against x509-limbo. | |
| x509-limbo: | |
| needs: analyze | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d | |
| with: | |
| sdk: stable | |
| - name: Install dependencies | |
| run: dart pub get | |
| # limbo.json is ~40 MB, and the revision is pinned in the runner script. | |
| - name: Cache x509-limbo testcases | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | |
| with: | |
| path: pkgs/boring/build/x509-limbo | |
| key: x509-limbo-${{ hashFiles('pkgs/boring/tool/run_x509_limbo_tests.sh') }} | |
| - name: Run x509-limbo conformance tests | |
| run: ./tool/run_x509_limbo_tests.sh | |
| # Re-run the vendoring script at the pinned revision, which also regenerates | |
| # the bindings, and fail if that changes anything. This keeps the checked-in | |
| # sources and bindings in sync with tool/REVISION. | |
| generated: | |
| # The bindings include struct layouts from the glibc headers, so they are | |
| # generated on a fixed image. Keep in sync with the refresh job. | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d | |
| with: | |
| sdk: dev | |
| - name: Regenerate at tool/REVISION | |
| run: ./tool/bump-boringssl-revision.sh "$(cat tool/REVISION)" | |
| # Also checks that every prebuilt target's asset exists in the pinned | |
| # release, since `fetch` fails for a target without a hash. | |
| - name: Regenerate the hashes of the pinned release | |
| run: dart run tool/regenerate_hashes.dart | |
| - name: Check for changes | |
| run: | | |
| if [ -n "$(git status --porcelain -- .)" ]; then | |
| git status --short -- . | |
| echo "::error::Generated files are out of date. Run ./tool/bump-boringssl-revision.sh \"\$(cat tool/REVISION)\" and dart run tool/regenerate_hashes.dart in pkgs/boring and commit the result." | |
| exit 1 | |
| fi | |
| # Weekly (and on manual runs), update BoringSSL to its latest revision and | |
| # open a PR if anything changed. The Dart Bot token is needed so that the | |
| # PR's CI runs. | |
| refresh: | |
| if: >- | |
| github.repository_owner == 'dart-lang' && | |
| (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | |
| # Keep in sync with the generated job. | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Generate Dart Bot token | |
| id: generate-token | |
| uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 | |
| with: | |
| client-id: ${{ vars.ECOSYSTEM_BOT_CLIENT_ID }} | |
| private-key: ${{ secrets.ECOSYSTEM_BOT_PRIVATE_KEY }} | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| persist-credentials: false | |
| - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d | |
| with: | |
| sdk: dev | |
| - name: Update BoringSSL | |
| id: refresh | |
| run: ./tool/bump-boringssl-revision.sh | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if [ -n "$(git status --porcelain -- .)" ]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # BoringSSL's X.509 behavior changes between revisions, and the | |
| # x509-limbo job fails on any divergence from the suite that | |
| # test/conformance/x509_limbo_expected_failures.txt does not list, and on | |
| # any listed testcase that started agreeing. Regenerate the list against | |
| # the new revision, so that the pull request shows a behavior change as | |
| # a diff of that file for review, rather than as a red check that needs | |
| # a manual push to the bot's branch. The bump script removes build/, so | |
| # the cached testcases are restored only now. | |
| - name: Cache x509-limbo testcases | |
| if: steps.check_changes.outputs.changed == 'true' | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 | |
| with: | |
| path: pkgs/boring/build/x509-limbo | |
| key: x509-limbo-${{ hashFiles('pkgs/boring/tool/run_x509_limbo_tests.sh') }} | |
| - name: Regenerate the x509-limbo expected failures | |
| if: steps.check_changes.outputs.changed == 'true' | |
| # A failure here (say, downloading the testcases) must not hold back | |
| # the update: the x509-limbo check on the pull request fails if the | |
| # list is stale, and says how to regenerate it. | |
| continue-on-error: true | |
| env: | |
| X509_LIMBO_REGENERATE: 1 | |
| run: ./tool/run_x509_limbo_tests.sh | |
| - name: Install changelog updater | |
| if: steps.check_changes.outputs.changed == 'true' | |
| run: | | |
| dart install --git-path pkgs/repo_manage https://github.com/dart-lang/ecosystem.git | |
| echo "$HOME/.local/state/Dart/install/bin" >> "$GITHUB_PATH" | |
| - name: Update changelog | |
| if: steps.check_changes.outputs.changed == 'true' | |
| run: >- | |
| report changelog --replace-pattern '^Update BoringSSL to ' | |
| "Update BoringSSL to [${SHORT_REVISION}](https://boringssl.googlesource.com/boringssl/+/${REVISION})." | |
| env: | |
| REVISION: ${{ steps.refresh.outputs.revision }} | |
| SHORT_REVISION: ${{ steps.refresh.outputs.short_revision }} | |
| - name: Create pull request | |
| id: create-pr | |
| if: steps.check_changes.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@86c87cfdd87dd582eb8b8f226cfec4e09d825326 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| committer: dart-ecosystem-bot <dart-ecosystem-bot@google.com> | |
| author: dart-ecosystem-bot <dart-ecosystem-bot@google.com> | |
| add-paths: pkgs/boring | |
| commit-message: "[boring] Update BoringSSL to ${{ steps.refresh.outputs.short_revision }}" | |
| branch: "boring-update-boringssl-${{ steps.refresh.outputs.short_revision }}" | |
| title: "[boring] Update BoringSSL to ${{ steps.refresh.outputs.short_revision }}" | |
| body: >- | |
| Automated update to the latest BoringSSL revision | |
| [`${{ steps.refresh.outputs.revision }}`](https://boringssl.googlesource.com/boringssl/+/${{ steps.refresh.outputs.revision }}), | |
| generated by `pkgs/boring/tool/bump-boringssl-revision.sh`. | |
| `test/conformance/x509_limbo_expected_failures.txt` was regenerated | |
| against this revision. A change to it is a change in which | |
| [x509-limbo](https://x509-limbo.com) testcases BoringSSL agrees | |
| with: review it before approving. | |
| delete-branch: true | |
| # Each run supersedes the bot's earlier pull requests of this kind, so | |
| # close them instead of leaving them for someone to clean up. | |
| - name: Close superseded pull requests | |
| if: steps.create-pr.outputs.pull-request-number != '' | |
| env: | |
| GH_TOKEN: ${{ steps.generate-token.outputs.token }} | |
| GH_REPO: ${{ github.repository }} | |
| NEW_PR: ${{ steps.create-pr.outputs.pull-request-number }} | |
| BRANCH_PREFIX: boring-update-boringssl- | |
| run: | | |
| gh pr list --state open --limit 100 --json number,headRefName,author | | |
| jq -r --arg prefix "$BRANCH_PREFIX" --argjson new "$NEW_PR" \ | |
| '.[] | select(.author.login == "app/dart-ecosystem-bot") | |
| | select(.headRefName | startswith($prefix)) | |
| | select(.number != $new) | .number' | | |
| while read -r pr; do | |
| gh pr close "$pr" --delete-branch --comment "Superseded by #$NEW_PR." | |
| done |