From b41c678da60d3193b341f693488fc1d47cda0317 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 19 May 2023 01:22:09 +0300 Subject: [PATCH 1/7] cicd: rollback runner version to link against older GLIBC --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f7452e0..e117f7dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: # 2. Add a new record to a matrix map in `cli/npm/install.js` - { runtime: linux-arm64 , target: aarch64-unknown-linux-gnu , os: ubuntu-latest , use-cross: true } - { runtime: linux-arm , target: arm-unknown-linux-gnueabihf , os: ubuntu-latest , use-cross: true } - - { runtime: linux-x64 , target: x86_64-unknown-linux-gnu , os: ubuntu-latest } + - { runtime: linux-x64 , target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 } #2272 - { runtime: linux-x86 , target: i686-unknown-linux-gnu , os: ubuntu-latest , use-cross: true } - { runtime: windows-arm64 , target: aarch64-pc-windows-msvc , os: windows-latest } - { runtime: windows-x64 , target: x86_64-pc-windows-msvc , os: windows-latest } From fcbc3db1ab6906d7e01222bff2cae6ec5e56fde6 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 19 May 2023 15:57:18 +0300 Subject: [PATCH 2/7] cicd: build - add a `run-tests` input parameter --- .github/workflows/build.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e117f7dc..aa569cf5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,12 +6,20 @@ env: CROSS_DEBUG: 1 on: - workflow_dispatch: workflow_call: inputs: ref: default: ${{ github.ref }} type: string + run-tests: + default: true + type: boolean + workflow_dispatch: + inputs: + run-tests: + description: Run tests + default: true + type: boolean jobs: build: @@ -141,34 +149,34 @@ jobs: run: make.sh CFLAGS="-Werror" -j - name: Build wasm library - if: ${{ !matrix.use-cross && !matrix.cli-only }} # No sense to build on the same Github runner hosts many times + if: ${{ !matrix.cli-only && !matrix.use-cross }} # No sense to build on the same Github runner hosts many times run: script/build-wasm - name: Build CLI run: $BUILD_CMD build --release --target=${{ matrix.target }} - name: Fetch fixtures - if: ${{ !matrix.cli-only }} # Don't fetch fixtures for only CLI building targets + if: ${{ inputs.run-tests && !matrix.cli-only }} # Don't fetch fixtures for only CLI building targets run: script/fetch-fixtures - name: Generate fixtures - if: ${{ !matrix.cli-only }} # Can't natively run CLI on Github runner's host + if: ${{ inputs.run-tests && !matrix.cli-only }} # Can't natively run CLI on Github runner's host run: script/generate-fixtures - name: Generate WASM fixtures - if: ${{ !matrix.use-cross && !matrix.cli-only }} # See comment for the "Build wasm library" step + if: ${{ inputs.run-tests && !matrix.cli-only && !matrix.use-cross }} # See comment for the "Build wasm library" step run: script/generate-fixtures-wasm - name: Run main tests - if: ${{ !matrix.cli-only }} # Can't natively run CLI on Github runner's host + if: ${{ inputs.run-tests && !matrix.cli-only }} # Can't natively run CLI on Github runner's host run: $BUILD_CMD test --target=${{ matrix.target }} - name: Run wasm tests - if: ${{ !matrix.use-cross && !matrix.cli-only }} # See comment for the "Build wasm library" step + if: ${{ inputs.run-tests && !matrix.cli-only && !matrix.use-cross }} # See comment for the "Build wasm library" step run: script/test-wasm - name: Run benchmarks - if: ${{ !matrix.use-cross && !matrix.cli-only }} # Cross-compiled benchmarks make no sense + if: ${{ inputs.run-tests && !matrix.cli-only && !matrix.use-cross }} # Cross-compiled benchmarks make no sense run: $BUILD_CMD bench benchmark -p tree-sitter-cli --target=${{ matrix.target }} - name: Upload CLI artifact From 3af763e4bec84dd3f1bcb3b950a4a38cce96521e Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 19 May 2023 23:36:48 +0300 Subject: [PATCH 3/7] cicd: build - add a `rust-test-threads` number input parameter --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa569cf5..5e216bb4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,10 @@ on: description: Run tests default: true type: boolean + rust-test-threads: + description: Number of Rust test threads + default: "" + type: string jobs: build: @@ -119,7 +123,7 @@ jobs: - name: Setup env extras env: - RUST_TEST_THREADS: ${{ matrix.rust-test-threads }} + RUST_TEST_THREADS: ${{ matrix.rust-test-threads || inputs.rust-test-threads || '' }} USE_CROSS: ${{ matrix.use-cross }} TARGET: ${{ matrix.target }} CC: ${{ matrix.cc }} From 1f42f1efc0f00980243c1a591296fa68c5395ae8 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 19 May 2023 15:57:40 +0300 Subject: [PATCH 4/7] cicd: show info about minimal required GLIBC version for CLI --- .github/workflows/build.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e216bb4..8f10d486 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,6 +72,8 @@ jobs: env: BUILD_CMD: cargo + EMSCRIPTEN_VERSION: "" + EXE: ${{ contains(matrix.target, 'windows') && '.exe' || '' }} defaults: run: @@ -159,6 +161,12 @@ jobs: - name: Build CLI run: $BUILD_CMD build --release --target=${{ matrix.target }} + - name: Info about CLI + if: ${{ startsWith(matrix.runtime, 'linux') }} + run: | + min_glibc=$(objdump -p target/$TARGET/release/tree-sitter${{ env.EXE }} | sed -nr 's/.*(GLIBC_.+).*/\1/p' | sort -uV | tail -n1) + echo "🔗 Minimal **glibc** version required for CLI: ${min_glibc}">> $GITHUB_STEP_SUMMARY + - name: Fetch fixtures if: ${{ inputs.run-tests && !matrix.cli-only }} # Don't fetch fixtures for only CLI building targets run: script/fetch-fixtures @@ -187,7 +195,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: tree-sitter.${{ matrix.runtime }} - path: target/${{ matrix.target }}/release/tree-sitter${{ contains(matrix.target, 'windows') && '.exe' || '' }} + path: target/${{ matrix.target }}/release/tree-sitter${{ env.EXE }} if-no-files-found: error retention-days: 7 From e783d8848d8aeb3f19b8e613efeb0bedec5f6881 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 19 May 2023 18:04:53 +0300 Subject: [PATCH 5/7] cicd: don't start release on draft PRs --- .github/workflows/CICD.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 941cec2a..90ac3a94 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -68,7 +68,8 @@ jobs: needs: [init, fast_checks, full_checks, min_version, build, sanitize] if: > github.event.pull_request.head.repo.full_name == github.repository && - startsWith(github.head_ref, 'release/v') + startsWith(github.head_ref, 'release/v') && + !github.event.pull_request.draft uses: ./.github/workflows/release.yml with: ref: ${{ needs.init.outputs.ref }} From 30dc31ff53b9786229c57c26b620e7b5c690ad95 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 19 May 2023 23:36:10 +0300 Subject: [PATCH 6/7] cicd: run tests on ready to review PRs --- .github/workflows/CICD.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 90ac3a94..9afc0e83 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -3,6 +3,11 @@ name: CICD on: workflow_dispatch: pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review push: branches-ignore: - release/v* From 010f288b3c67d16f2e3e2a590332c8021a9e4d16 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Sat, 20 May 2023 01:52:31 +0300 Subject: [PATCH 7/7] cicd: move branch locality checking to the release workflow --- .github/workflows/CICD.yml | 2 +- .github/workflows/release.yml | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 9afc0e83..fcdb6ea9 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -72,7 +72,7 @@ jobs: name: Release needs: [init, fast_checks, full_checks, min_version, build, sanitize] if: > - github.event.pull_request.head.repo.full_name == github.repository && + github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/v') && !github.event.pull_request.draft uses: ./.github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 979d95a3..1b75dc96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,10 +12,14 @@ jobs: name: Check permissions runs-on: ubuntu-latest outputs: - release_allowed: ${{ steps.maintainer.outputs.is_maintainer == 'true' }} + release_allowed: > + ${{ + steps.maintainer.outputs.is_maintainer == 'true' && + steps.local_branch.outputs.is_local == 'true' + }} steps: - - name: Is maintainer + - name: Initated by a maintainer id: maintainer env: GH_TOKEN: ${{ github.token }} @@ -31,6 +35,13 @@ jobs: echo "is_maintainer=true" >> $GITHUB_OUTPUT fi + - name: The ref branch is local + id: local_branch + env: + is_local: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + run: | + echo "is_local=${is_local}" >> $GITHUB_OUTPUT + release: name: Release needs: permissions