From 400f3e66c79f07dce6c9e2eeb495113265530c9c Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 21 Dec 2024 14:13:30 -0500 Subject: [PATCH] ci: update workflows --- .github/workflows/ci.yml | 61 ++++++++++++++------------ .github/workflows/fuzz.yml | 15 +++---- .github/workflows/lint.yml | 19 +++++--- .github/workflows/publish.yml | 35 +++++++++++++++ .github/workflows/release.yml | 82 ----------------------------------- 5 files changed, 88 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6e1e05..a2a572f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,37 +1,44 @@ name: CI + on: push: - branches: - - master + branches: [master] + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp pull_request: - branches: - - master + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + jobs: test: - runs-on: ${{ matrix.os }} + name: Test parser + runs-on: ${{matrix.os}} strategy: - fail-fast: true + fail-fast: false matrix: - os: [macos-latest, ubuntu-latest] + os: [ubuntu-latest, windows-latest, macos-14] steps: - - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up tree-sitter + uses: tree-sitter/setup-action/cli@v2 + - name: Run tests + uses: tree-sitter/parser-test-action@v2 with: - submodules: true - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install - - run: npm test - test_windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install - - run: npm run-script test-windows + test-rust: true + test-node: true + test-python: true + test-go: true + test-swift: true diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 78f87f1..ad67d88 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -2,21 +2,18 @@ name: Fuzz Parser on: push: + branches: [master] paths: - src/scanner.c pull_request: paths: - src/scanner.c - workflow_dispatch: jobs: - test: - name: Parser fuzzing + fuzz: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: vigoux/tree-sitter-fuzz-action@v1 - with: - language: kconfig - external-scanner: src/scanner.c - time: 60 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run fuzzer + uses: tree-sitter/fuzz-action@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d94f7f3..96f1a4d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,18 +2,25 @@ name: Lint on: push: - branches: - - master + branches: [master] + paths: + - grammar.js pull_request: - branches: - - "**" + paths: + - grammar.js jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + cache: npm + node-version: ${{vars.NODE_VERSION}} - name: Install modules - run: npm install + run: npm ci --legacy-peer-deps - name: Run ESLint run: npm run lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..35459aa --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish packages + +on: + push: + tags: ["*"] + +permissions: + contents: write + id-token: write + attestations: write + +jobs: + github: + uses: tree-sitter/workflows/.github/workflows/release.yml@main + with: + generate: true + attestations: true + npm: + uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main + secrets: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + with: + generate: true + crates: + uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main + secrets: + CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}} + with: + generate: true + pypi: + uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main + secrets: + PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}} + with: + generate: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 2c76331..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: ["CI"] - types: - - completed - -permissions: - contents: write - pull-requests: write - -jobs: - release: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/master' }} - steps: - - uses: google-github-actions/release-please-action@v3 - id: release - with: - release-type: node - package-name: tree-sitter-kconfig - - - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Update Rust version - run: | - git fetch origin release-please--branches--master--components--tree-sitter-kconfig - git checkout release-please--branches--master--components--tree-sitter-kconfig - - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - - repo_name="${{ github.repository }}" - repo_name="${repo_name##*/}" - version=$(grep -o '"version": *"[^"]*"' package.json | sed 's/"version": "\(.*\)"/\1/') - - sed -i "s/version = \"[^\"]*\"/version = \"$version\"/g" Cargo.toml - sed -i "s/$repo_name = \"[^\"]*\"/$repo_name = \"$version\"/g" bindings/rust/README.md - - git add Cargo.toml bindings/rust/README.md - git commit --amend --no-edit - git push -f - - - name: Setup Node - if: ${{ steps.release.outputs.release_created }} - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: "https://registry.npmjs.org" - - name: Publish to NPM - if: ${{ steps.release.outputs.release_created }} - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - run: npm publish - - - name: Setup Rust - if: ${{ steps.release.outputs.release_created }} - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Publish to Crates.io - if: ${{ steps.release.outputs.release_created }} - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - - name: Tag stable versions - if: ${{ steps.release.outputs.release_created }} - run: | - git checkout master - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" - git tag -d stable || true - git push origin :stable || true - git tag -a stable -m "Last Stable Release" - git push origin stable