From 23fc954d362caec0abf7f316b37a92d6f9582053 Mon Sep 17 00:00:00 2001 From: Jeevitha P Date: Wed, 21 Feb 2024 17:30:12 +0530 Subject: [PATCH] workflows for tests, release and lint --- .github/workflows/lint.yml | 20 +++++++++++++++++ .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 34 ++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3960f77 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened, auto_merge_enabled] + +concurrency: + group: lint-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v4 + - uses: actions/checkout@v4 + - run: npm i + - run: npm run lint \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ea8f78b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + workflow_dispatch: + +permissions: + contents: write + +jobs: + + publish-npm: + runs-on: ubuntu-latest + environment: npm + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + + - name: Run Unit Tests + run: | + npm install + npm run lint + npm run test + + - name: get-version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.2.3 + - name: Parse changelog + id: parse-changelog + uses: schwma/parse-changelog-action@v1.0.0 + with: + version: '${{ steps.package-version.outputs.current-version }}' + - name: Create a GitHub release + uses: ncipollo/release-action@v1 + with: + tag: 'v${{ steps.package-version.outputs.current-version }}' + body: '${{ steps.parse-changelog.outputs.body }}' + - run: npm publish --access public --dry + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cff5173 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened, auto_merge_enabled] + +# Allow parallel jobs on `main`, so that each commit is tested. For PRs, run only the latest commit. +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + name: Node.js ${{ matrix.node }} + + strategy: + fail-fast: true + matrix: + node: [20, 18] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + + - run: npm i + - run: npm run lint + - run: npm test + env: + FORCE_COLOR: true \ No newline at end of file