diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb17c44..d7989f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,31 +4,64 @@ on: push: branches: - master + - main + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp + - .github/workflows/ci.yml pull_request: - branches: - - "**" + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp + - .github/workflows/ci.yml + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true jobs: test: - runs-on: ${{ matrix.os }} + name: Test parser + runs-on: ${{matrix.os}} + if: >- + !github.event.repository.is_template && + github.event.head_commit.message != 'Initial commit' 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 - - uses: actions/setup-node@v2 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up tree-sitter + uses: tree-sitter/setup-action/cli@v1 + - name: Run tests + uses: tree-sitter/parser-test-action@v2 with: - node-version: 16 - - run: npm install - - run: npm test - - test_windows: - runs-on: windows-2019 + test-rust: ${{runner.os == 'Linux'}} + fuzz: + name: Fuzz scanner + runs-on: ubuntu-latest + if: >- + !github.event.repository.is_template && + github.event.head_commit.message != 'Initial commit' steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 - with: - node-version: 16 - - run: npm install - - run: npm run-script test-windows + - name: Checkout repository + uses: actions/checkout@v4 + - name: Check for scanner changes + id: scanner-check + shell: sh + run: |- + { + test -f src/scanner.c && ! git diff --quiet HEAD^ -- "$_" && + printf 'changed=true\n' || printf 'changed=false\n' + } >> "$GITHUB_OUTPUT" + - name: Run fuzzer + uses: tree-sitter/fuzz-action@v4 + if: steps.scanner-check.outputs.changed == 'true' diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml deleted file mode 100644 index 85a7629..0000000 --- a/.github/workflows/fuzz.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Fuzz Parser - -on: - push: - paths: - - src/scanner.c - pull_request: - paths: - - src/scanner.c - workflow_dispatch: - -jobs: - test: - name: Parser fuzzing - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: vigoux/tree-sitter-fuzz-action@v1 - with: - language: squirrel - external-scanner: src/scanner.c - time: 60 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index d94f7f3..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Lint - -on: - push: - branches: - - master - pull_request: - branches: - - "**" - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install modules - run: npm install - - name: Run ESLint - run: npm run lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index faeffaa..455e952 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,81 +1,23 @@ -name: Publish +name: Publish package on: - pull_request: - types: [closed] + push: + tags: ["*"] -permissions: - contents: write +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install - - run: npm test - - publish: - if: github.event.pull_request.merged && startsWith(github.event.pull_request.title, 'chore(master):') - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.merge_commit_sha }} - token: ${{ secrets.GITHUB_TOKEN }} - - name: Extract version - id: extract_version - run: | - PR_TITLE="${{ github.event.pull_request.title }}" - VERSION=$(echo "$PR_TITLE" | grep -oP '(?<=release ).*$') - echo "::set-output name=version::$VERSION" - - name: Update versions - run: | - version="${{ steps.extract_version.outputs.version }}" - repo_name="${{ github.repository }}" - repo_name="${repo_name##*/}" - - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git fetch origin master - git checkout master - - sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$version\"/g" package.json - sed -i "s/version = \"[^\"]*\"/version = \"$version\"/g" Cargo.toml - sed -i "s/$repo_name = \"[^\"]*\"/$repo_name = \"$version\"/g" bindings/rust/README.md - - git add package.json Cargo.toml bindings/rust/README.md - git commit -m "chore(manifests): bump version to $version" - git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:master - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://registry.npmjs.org/ - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Publish to Crates.io - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - uses: actions/checkout@v3 - - name: Tag stable versions - run: | - 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 + 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}} + pypi: + uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main + secrets: + PYPI_API_TOKEN: ${{secrets.PYPI_TOKEN}}