From 73c74d24fc903c591231bc8439e862c024406394 Mon Sep 17 00:00:00 2001 From: busticated Date: Sun, 17 Dec 2023 15:31:10 -0800 Subject: [PATCH] wire up ci bits --- .github/pull_request_template.md | 44 +++++++++++++++++++++++++ .github/workflows/ci.yaml | 56 ++++++++++++++++++++++++++++++++ .github/workflows/publish.yaml | 32 ++++++++++++++++++ .github/workflows/test.yaml | 47 +++++++++++++++++++++++++++ bin/ci-set-commit-info.sh | 24 ++++++++++++++ package.json | 10 ++++-- 6 files changed, 211 insertions(+), 2 deletions(-) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/test.yaml create mode 100755 bin/ci-set-commit-info.sh diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..8679c03 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,44 @@ +## Description + + + + +## How to Test + + + +1. +2. +3. + +**Outcome** + + + + +## Related / Discussions + + + + +## Completeness + +- [x] PR opened :tada: +- [ ] Testing instructions have been provided +- [ ] Docs have been updated (`npm run docs:build`) +- [ ] Changes adhere to repo [conventions](https://github.com/busticated/jsville/DEVELOPMENT.md#conventions) +- [ ] Development [How-To's](https://github.com/busticated/jsville/DEVELOPMENT.md#how-tos--faqs) have been provided +- [ ] Branch is rebased against _target_ (typically `main`) + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..87fef03 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,56 @@ +name: Run CI/CD Jobs + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +concurrency: + group: 'busticated/jsville' + +jobs: + info: + name: Harvest Commit Info + runs-on: ubuntu-latest + outputs: + tags: ${{ steps.info.outputs.tags }} + steps: + - name: Checkout Source Code + uses: actions/checkout@v4 + with: + fetch-tags: true + - name: Set Info + id: info + run: ./bin/ci-set-commit-info.sh + + debug: + name: Debug + needs: info + runs-on: ubuntu-latest + steps: + - name: Log Info + run: | + echo ":::: GIT REF: ${{github.ref}}" + echo ":::: GIT REF_NAME: ${{github.ref_name}}" + echo ":::: TAGS: ${{needs.info.outputs.tags}}" + - name: Test Tag Check + if: contains(needs.info.outputs.tags, '@') + run: | + echo ":::: FOUND TAGS" + test: + name: Run Tests + needs: [info, debug] + uses: ./.github/workflows/test.yaml + secrets: inherit + + publish: + name: Publish + needs: [info, debug, test] + if: github.ref_name == 'main' && contains(needs.info.outputs.tags, '@bust/') + uses: ./.github/workflows/publish.yaml + secrets: inherit + with: + tags: ${{needs.info.outputs.tags}} + diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..8a546cb --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,32 @@ +name: Publish + +on: + workflow_call: + inputs: + tags: + type: string + required: true + secrets: + NPM_TOKEN: + required: true + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout Source Code + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install Dependencies + uses: bahmutov/npm-install@v1 + - name: Upload to NPM + run: | + npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" + echo ":::: Publishing as $(npm whoami)" + npm run package:publish + echo ":::: Done!" + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..c65ac10 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,47 @@ +name: Test + +on: + workflow_call: + secrets: + NPM_TOKEN: + required: true + +jobs: + test: + name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + architecture: + - x64 + node_version: + - 18 + - 20 + experimental: + - false + include: + - node_version: 21 + experimental: true + os: ubuntu-latest + architecture: x64 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node_version }} + architecture: ${{ matrix.architecture }} + - name: Install Dependencies + uses: bahmutov/npm-install@v1 + - name: Run tests + run: npm test + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + diff --git a/bin/ci-set-commit-info.sh b/bin/ci-set-commit-info.sh new file mode 100755 index 0000000..0b2059b --- /dev/null +++ b/bin/ci-set-commit-info.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +echo +echo ":::: GIT Commit:" +git log -1 + +echo +echo ":::: GIT Tags:" +git tag --points-at HEAD + +taglistStr=$(git tag --points-at HEAD) +declare -a taglist=($taglistStr) +tags="" + +for tag in "${taglist[@]}"; do + tags="${tags} ${tag}" +done + +echo +echo ":::: Set Action Output: Tags:" +echo "tags=$tags" >> $GITHUB_OUTPUT +echo $tags +echo + diff --git a/package.json b/package.json index 54cd44a..78626cd 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,22 @@ ], "scripts": { "start": "echo \"Error: no source code available\" && exit 1", - "test": "npm run test --workspaces", + "test": "npm run lint && npm run typecheck && npm run test --workspaces", "lint": "eslint . --ext .js,.jsx,.mjs,.ts,.tsx --ignore-path .gitignore", "lint:fix": "npm run lint -- --fix", "typecheck": "npm run typecheck --workspaces", "build": "npm run build --workspaces", + "clean": "npm run clean --workspaces", + "clean:modules": "npm run clean:modules --workspaces", "docs:build": "npm run docs:build --workspaces", "package:create": "node ./bin/create-package.mjs", "package:list": "npm list --workspaces", + "package:publish": "lerna publish from-package --yes --no-verify-access", "changelog:show": "npm run changelog:show --workspaces", - "changelog:update": "npm run changelog:update --workspaces" + "changelog:update": "npm run changelog:update --workspaces", + "release:dry-run": "lerna exec -- npm pack --dry-run --loglevel notice && lerna changed", + "release": "lerna version", + "todo": "git grep -P -e 'TODO\\s?(.*)' --ignore-case --heading --break --context=2 --full-name --line-number -- :^./package.json :^./README.md" }, "devDependencies": { "@types/node": "^20.10.3",