From 009def4ae38ec30e5b40beeae26efe93484ab286 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Fri, 9 May 2025 10:18:25 +0300 Subject: [PATCH] ci: update workflows - Replace build workflow with CI & fuzz - Add GitHub & NPM release workflow --- .github/workflows/build.yaml | 33 ----------------- .github/workflows/ci.yaml | 65 ++++++++++++++++++++++++++++++++++ .github/workflows/fuzz.yaml | 28 +++++++++++++++ .github/workflows/release.yaml | 28 +++++++++++++++ 4 files changed, 121 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/fuzz.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 61de8ce..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: build - -on: [pull_request] - -jobs: - compile: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - compiler: [gcc, clang, zig cc] - include: - - os: windows-latest - compiler: cl.exe - - name: compile - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - - if: matrix.os == 'windows-latest' && matrix.compiler == 'gcc' - uses: csukuangfj/setup-mingw@v2.2.1 - with: - version: '12.2.0' - - - if: matrix.compiler == 'cl.exe' && matrix.os == 'windows-latest' - uses: seanmiddleditch/gha-setup-vsdevenv@master - - - if: matrix.compiler == 'zig cc' - uses: goto-bus-stop/setup-zig@v2 - - - name: build - run: ${{ matrix.compiler }} -o scanner.o -I./src -c src/scanner.c diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..0c86748 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: [main] + paths: + - grammar.js + - make_grammar.js + - src/** + - test/** + - example/** + - bindings/** + - binding.gyp + pull_request: + paths: + - grammar.js + - make_grammar.js + - src/** + - test/** + - example/** + - bindings/** + - binding.gyp + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +jobs: + test: + name: Test parser + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up tree-sitter + uses: tree-sitter/setup-action/cli@v1 + - name: Regenerate with ABI 14 + # TODO: remove when node & swift support ABI 15 + run: |- + tree-sitter generate --abi=14 + cd dialects/terraform + tree-sitter generate --abi=14 + - name: Run parser and binding tests + uses: tree-sitter/parser-test-action@v2 + with: + test-node: true + test-rust: ${{runner.os == 'Linux'}} + test-swift: ${{runner.os == 'macOS'}} + - name: Parse sample files + uses: tree-sitter/parse-action@v4 + id: parse-files + with: + files: |- + example/**/*.hcl + example/**/*.tf + - name: Upload failures artifact + uses: actions/upload-artifact@v4 + if: "!cancelled() && steps.parse-files.outcome == 'failure'" + with: + name: failures-${{runner.os}} + path: ${{steps.parse-files.outputs.failures}} diff --git a/.github/workflows/fuzz.yaml b/.github/workflows/fuzz.yaml new file mode 100644 index 0000000..67eeac0 --- /dev/null +++ b/.github/workflows/fuzz.yaml @@ -0,0 +1,28 @@ +name: fuzz + +on: + push: + branches: [main] + paths: + - src/scanner.c + - dialects/*/src/scanner.c + pull_request: + paths: + - src/scanner.c + - dialects/*/src/scanner.c + +jobs: + fuzz: + name: Parser fuzzing + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + directory: [".", "dialects/terraform"] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run fuzzer + uses: tree-sitter/fuzz-action@v4 + with: + directory: ${{matrix.directory}} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..f38ae94 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,28 @@ +name: release + +on: + push: + tags: ["*"] + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +permissions: + contents: write + id-token: write + attestations: write + +jobs: + release: + uses: tree-sitter/workflows/.github/workflows/release.yml@main + with: + attestations: true + npm: + uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main + secrets: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + crates: + uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main + secrets: + CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_TOKEN}}