Skip to content

Commit

Permalink
wire up ci bits
Browse files Browse the repository at this point in the history
  • Loading branch information
busticated committed Dec 17, 2023
1 parent 679c947 commit 73c74d2
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Description

<!--
Please write a brief description of the changes introduced by this PR: What issues(s) does it address? How does it solve them? For ui-centric changes, please include a screenshot or video.
-->


## How to Test

<!--
What steps can a reviewer take to manually test your changes?
-->

1.
2.
3.

**Outcome**

<!--
What should a reviewer expect to happen in order to confirm your changes are working as expected?
-->


## Related / Discussions

<!--
Link to related PRs or Issues
e.g. https://github.com/busticated/jsville/pull/1
Link to any relevant community discussions
e.g. As discussed here: https://github.com/<path-to-topic>
-->


## 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`)

56 changes: 56 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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}}

32 changes: 32 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
47 changes: 47 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

24 changes: 24 additions & 0 deletions bin/ci-set-commit-info.sh
Original file line number Diff line number Diff line change
@@ -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

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 73c74d2

Please sign in to comment.