Skip to content

Commit

Permalink
ci: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Dec 22, 2024
1 parent 28aae81 commit 8da144c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 102 deletions.
61 changes: 40 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,52 @@ name: CI

on:
push:
branches:
- master
branches: [master]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:
branches:
- "**"
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
- uses: actions/setup-node@v2
- 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:
node-version: 16
- run: npm install
- run: npm test

test_windows:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
test-rust: true
test-node: true
test-python: true
test-go: true
test-swift: true
- name: Set up examples
run: |-
git clone https://github.com/puppetlabs/puppet.git examples/puppet --single-branch --depth=1 --filter=blob:none
- name: Parse examples
uses: tree-sitter/parse-action@v4
with:
node-version: 16
- run: npm install
- run: npm run-script test-windows
files: |
examples/**/*.pp
!examples/puppet/spec/fixtures/unit/parser/functions/create_resources/foo/manifests/wrongdefine.pp
19 changes: 13 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
103 changes: 28 additions & 75 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,35 @@
name: Release
name: Publish packages

on:
workflow_run:
workflows: ["CI"]
types:
- completed
push:
tags: ["*"]

permissions:
contents: write
pull-requests: write
id-token: write
attestations: 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-puppet

- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Update Rust version
run: |
git fetch origin release-please--branches--master--components--tree-sitter-puppet
git checkout release-please--branches--master--components--tree-sitter-puppet
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
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

0 comments on commit 8da144c

Please sign in to comment.