From 778990bb981659dab82b52ea3ebbac8a39c27328 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Mon, 11 Mar 2024 17:38:45 +0200 Subject: [PATCH] ci: use upstream actions --- .github/workflows/ci.yml | 73 +++++++++++++++++++++++++++++++++++ .github/workflows/node.js.yml | 43 --------------------- .github/workflows/publish.yml | 19 +++++++++ 3 files changed, 92 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/node.js.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..40d3f09 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +name: CI + +on: + push: + branches: [split_parser] + paths: + - "scripts/*" + - "common/*" + - "*/grammar.js" + - "*/src/**" + - "*/test/**" + - "bindings/**" + - "binding.gyp" + pull_request: + paths: + - "scripts/*" + - "common/*" + - "*/grammar.js" + - "*/src/**" + - "*/test/**" + - "bindings/**" + - "binding.gyp" + +jobs: + test: + name: Test parsers + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-14] + steps: + - name: Set up repository + uses: tree-sitter/parser-setup-action@v1.2 + with: + node-version: ${{vars.NODE_VERSION}} + - name: Build with all extensions + run: npm run build + env: + ALL_EXTENSIONS: 1 + - name: Run tests + uses: tree-sitter/parser-test-action@v1.2 + - name: Rebuild with default extensions + run: npm run build + env: + EXTENSION_DEFAULT: 1 + - name: Verify grammar consistency + run: git diff --exit-code -- */src/grammar.json + fuzz: + name: Fuzz parsers + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + parser: [tree-sitter-markdown, tree-sitter-markdown-inline] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Check for scanner changes + id: scanner-changes + run: |- + if git diff --quiet HEAD^ -- '${{matrix.parser}}/src/scanner.c'; then + printf 'changed=false\n' >> "$GITHUB_OUTPUT" + else + printf 'changed=true\n' >> "$GITHUB_OUTPUT" + fi + - name: Fuzz ${{matrix.parser}} parser + uses: tree-sitter/fuzz-action@v4 + if: steps.scanner-changes.outputs.changed == 'true' + with: + directory: ${{matrix.parser}} diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index f271e12..0000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,43 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI - -on: - push: - branches: [ "split_parser" ] - pull_request: - branches: [ "split_parser" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js 14 - uses: actions/setup-node@v3 - with: - node-version: 14 - cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - name: Check grammar is compiled correctly - run: git diff --exit-code - test: - - runs-on: ubuntu-latest - env: - ALL_EXTENSIONS: 1 - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js 14 - uses: actions/setup-node@v3 - with: - node-version: 14 - cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9194acb --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: Publish package + +on: + push: + tags: ["*"] + +jobs: + npm: + uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main + with: + package-name: "@tree-sitter-grammars/tree-sitter-markdown" + secrets: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + crates: + uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main + with: + package-name: tree-sitter-md + secrets: + CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_TOKEN}}