From 5cfb5f2355035bc512875ee701d4118c8d0a622b Mon Sep 17 00:00:00 2001 From: web-mech Date: Sat, 17 Aug 2024 19:57:30 -0400 Subject: [PATCH] ci(gha): add project workflows add test, docs, release, and format jobs --- .github/workflows/docs.yml | 49 +++++++++++++++++++++++++++++++++++ .github/workflows/format.yml | 29 +++++++++++++++++++++ .github/workflows/node.js.yml | 31 ---------------------- .github/workflows/release.yml | 26 +++++++++++++++++++ .github/workflows/test.yml | 24 +++++++++++++++++ 5 files changed, 128 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/format.yml delete mode 100644 .github/workflows/node.js.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..87f9b99 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,49 @@ +name: Deploy Docs to Pages + +on: + push: + branches: ['main'] + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: 'pages' + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 20 + - name: Install Dependencies + run: yarn install + - name: Build + run: | + yarn build + yarn typedoc + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload docs folder + path: 'docs' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..2432725 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,29 @@ +name: Format + +on: + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +jobs: + lint-and-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v1 + with: + node-version: 20 + - run: yarn install + - run: | + yarn lint:fix + yarn prettier + - name: Create Lint PR + uses: peter-evans/create-pull-request@v6.0.5 + with: + base: ${{ github.head_ref }} + commit-message: 'style: ESlint + Prettier Lint' + title: ESlint + Prettier Format + body: Format * to standard format. + branch: ${{ github.event.pull_request.head.ref }}-fmt + add-paths: | + src/* diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 738a8e7..0000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,31 +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://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - -name: Node.js CI - -on: - push: - branches: [ "next" ] - pull_request: - branches: [ "next" ] - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [14.x, 16.x, 18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - name: Install NPM Dependencies - run: npm install - - run: npm test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..30d11d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release + +on: + push: + branches: ['main'] + +jobs: + publish-gpr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v1 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: yarn install + - run: yarn global add standard-version + - run: git config --global user.email "action@github.com" + - run: git config --global user.name "GitHub Action" + - uses: EndBug/add-and-commit@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: standard-version + - run: git push --follow-tags origin main && npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fe9fe84 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Run the tests + +on: + pull_request: + branches: ['main'] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install NPM Dependencies + run: yarn install + - run: yarn test