From adf879c205c31369ff452c770f8d6b201d890f01 Mon Sep 17 00:00:00 2001 From: gbprod Date: Mon, 17 Apr 2023 17:06:57 +0200 Subject: [PATCH] chore: updates workflows (#35) --- .github/workflows/ci.yml | 69 ++++++++++++++++----------------- .github/workflows/crates.yml | 21 ---------- .github/workflows/npm.yml | 23 ----------- .github/workflows/publish.yaml | 71 ++++++++++++++++++++++++++++++++++ .prettierrc | 14 +++---- Cargo.toml | 4 +- README.md | 2 +- package-lock.json | 4 +- package.json | 2 +- 9 files changed, 117 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/crates.yml delete mode 100644 .github/workflows/npm.yml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f50dd75..11544a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,43 +1,40 @@ name: CI on: - pull_request: - branches: - - '**' - push: - branches: - - 'main' + pull_request: + branches: + - '**' + push: + branches: + - 'main' concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - test: - name: Run validation tests - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: Install dependencies - run: npm install - - - name: Run tree-sitter tests - run: npm test - - - name: Ensure generated parser files are up-to-date - # On Windows, tree-sitter generate results in a diff, not sure why - if: runner.os != 'Windows' - run: | - git status - test -z "$(git status --porcelain)" + test: + name: Run validation tests + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm ci + - name: Run tree-sitter tests + run: npm test + - name: Ensure generated parser files are up-to-date + # On Windows, tree-sitter generate results in a diff, not sure why + if: runner.os != 'Windows' + run: | + git status + test -z "$(git status --porcelain)" diff --git a/.github/workflows/crates.yml b/.github/workflows/crates.yml deleted file mode 100644 index af40c65..0000000 --- a/.github/workflows/crates.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Publish to Crates -on: - release: - types: [created] - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: cargo publish --token ${CRATES_TOKEN} - env: - CRATES_TOKEN: ${{ secrets.CRATES_GBPROD_GITCOMMIT }} diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml deleted file mode 100644 index 1cf7f8a..0000000 --- a/.github/workflows/npm.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Publish to NPM -on: - release: - types: [created] - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Node - uses: actions/setup-node@v2 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies and build 🔧 - run: npm ci && npm run build - - name: Publish package on NPM 📦 - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_GBPROD_GITCOMMIT }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..21cb29f --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,71 @@ +name: Publish +on: + release: + types: [released] + workflow_dispatch: + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - name: Update npm version + run: npm version ${GITHUB_REF_NAME#v} --no-git-tag-version + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Install cargo bump + run: cargo install cargo-bump + - name: Update cargo version + run: cargo bump ${GITHUB_REF_NAME#v} + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'chore: bump version' + branch: main + + publish_npm: + runs-on: ubuntu-latest + needs: bump + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: main + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies and build 🔧 + run: npm ci && npm run build + - name: Publish package on NPM 📦 + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_GBPROD_GITCOMMIT }} + + publish_crates: + runs-on: ubuntu-latest + needs: bump + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: main + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: cargo publish --token ${CRATES_TOKEN} + env: + CRATES_TOKEN: ${{ secrets.CRATES_GBPROD_GITCOMMIT }} diff --git a/.prettierrc b/.prettierrc index b6a98dd..bb0a4dd 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,9 +1,9 @@ { - "semi": true, - "singleQuote": true, - "trailingComma": "es5", - "jsxBracketSameLine": true, - "printWidth": 120, - "arrowParens": "always", - "tabWidth": 2 + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "jsxBracketSameLine": true, + "printWidth": 80, + "arrowParens": "always", + "tabWidth": 2 } diff --git a/Cargo.toml b/Cargo.toml index f2b0c39..36684ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tree-sitter-gitcommit" description = "gitcommit grammar for the tree-sitter parsing library" -version = "0.0.1" +version = "0.3.0" keywords = ["incremental", "parsing", "gitcommit"] categories = ["parsing", "text-editors"] repository = "https://github.com/tree-sitter/tree-sitter-gitcommit" @@ -20,7 +20,7 @@ include = [ path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = "~0.20.3" +tree-sitter = ">= 0.19" [build-dependencies] cc = "1.0" diff --git a/README.md b/README.md index 674e160..be3965d 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The currently supported locales are listed below: ## Note about injected languages -This parser _only_ parse git commit subject, message and generated comments, it doesn't handle diff and git rebase informations that could be included. +This parser _only_ parses git commit subject, message and generated comments, it doesn't handle diff and git rebase information that could be included. To handle that, you must have `diff` and `git_rebase` tree-sitter grammars installed and add injection queries. If you're using Neovim and [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter), you just have to be sure that `diff` and `git_rebase` are installed (using `TSInstall diff git_rebase` for example). diff --git a/package-lock.json b/package-lock.json index a600f1c..6652080 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tree-sitter-gitcommit", - "version": "1.0.0", + "version": "0.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tree-sitter-gitcommit", - "version": "1.0.0", + "version": "0.3.1", "license": "WTFPL", "dependencies": { "nan": "^2.17.0" diff --git a/package.json b/package.json index 9a7a443..9cf7b7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tree-sitter-gitcommit", - "version": "1.0.0", + "version": "0.3.0", "description": "A tree-sitter grammar for git commit messages", "main": "bindings/node", "scripts": {