This repository was archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7825e5
commit 1c06433
Showing
16 changed files
with
769 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
dist | ||
dist | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ on: | |
branches: | ||
- main | ||
- next | ||
- next-major | ||
- alpha | ||
- beta | ||
# N.x (maintenance release branches) | ||
|
@@ -21,25 +20,23 @@ jobs: | |
publish: | ||
name: publish | ||
runs-on: ubuntu-latest | ||
# TODO: Remove if from release workflow once library is ready to release | ||
if: ${{ false }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3.0.0 | ||
|
||
- name: Use Node.js ${{ env.NODE_VERSION }} | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v3.0.0 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
cache: 'yarn' | ||
cache: yarn | ||
|
||
- name: Configure package manager | ||
run: | | ||
echo Configuring NPM_TOKEN globally for .npmrc | ||
npm config set '//registry.npmjs.org/:_authToken' ${{ env.NPM_TOKEN }} | ||
npm whoami | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
# NOTE: Skipped since we only publish to Github Packages | ||
# - name: Configure package manager | ||
# run: | | ||
# npm config set '//registry.npmjs.org/:_authToken' ${{ env.NPM_TOKEN }} | ||
# npm whoami | ||
# env: | ||
# NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
@@ -49,15 +46,17 @@ jobs: | |
|
||
- name: Test | ||
run: yarn test --coverage --silent | ||
|
||
- name: Build | ||
run: yarn build | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload coverage to Coveralls | ||
uses: coverallsapp/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v2 | ||
id: semantic | ||
|
@@ -74,16 +73,32 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push updates to branch for major version | ||
# If a new version is published, i.e. v1.2.3 then this step will update | ||
# branch "v1" to this commit. | ||
# https://github.com/reside-eng/workflow-status-notification-action/branches | ||
# The dist folder (built) is included so that action can be used directly from Github | ||
# ref (where exact versions can pull from npm) | ||
if: steps.semantic.outputs.new_release_published == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# NOTE: Git user must be set in order for amend of commit to add dist folder | ||
# --force is used because dist is within gitignore | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add --force dist | ||
git commit -C HEAD --amend | ||
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v${{steps.semantic.outputs.new_release_major_version}} | ||
notification: | ||
# TODO: Remove if from release workflow once library is ready to release | ||
if: ${{ false }} | ||
# if: always() | ||
if: always() | ||
name: notification | ||
needs: [publish] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- uses: technote-space/[email protected] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ dist | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,128 @@ | ||
<!-- Replace this title and any other reference to `template-library` with | ||
the UI library's name – i.e. fastify-tools --> | ||
|
||
<div align="center"> | ||
<h1>@side/apollo-tools</h1> | ||
<!-- TODO: Replace with actual description of the UI application --> | ||
<div>Library created from reside-eng/template-library</div> | ||
<h1>@side/upload-coverage-base-action</h1> | ||
<div>Custom github action for uploading base branch coverage on pull_request close event (instead of default branch push)</div> | ||
</br> | ||
</div> | ||
|
||
<div align="center"> | ||
|
||
<!-- TODO: Uncomment package specific badges below --> | ||
<!-- [![NPM version][npm-image]][npm-url] | ||
[![License][license-image]][license-url] --> | ||
|
||
[![Build Status][build-status-image]][build-status-url] | ||
[![semantic-release][semantic-release-icon]][semantic-release-url] | ||
[![Code Style][code-style-image]][code-style-url] | ||
|
||
</div> | ||
|
||
This is the template repository for creating additional Next.js UI applications. | ||
Once a new repository has been created off this template, follow the steps below | ||
to finalize the initial setup process: | ||
|
||
1. Replace all references of `template-library` with the name of this application | ||
1. Create a new file starting your functionality using `src/placeholder.ts` and `src/placeholder.test.ts` as an example | ||
1. Remove `src/placeholder.ts` and `src/placeholder.test.ts` files | ||
1. Find all relevant `TODO:` references and make adjustments accordingly | ||
1. Set general repository settings: | ||
a. Only allow squash and merge | ||
a. Allow auto-merge | ||
a. Allow deletion of head branches | ||
1. Manage access to the repo by adding the teams that need permissions. This is required for automatic PR review assignment. | ||
1. Set branch permissions for `main` to set required PR verifications for CI | ||
1. Start making PRs with basic functionality - continue to next section once library is publishable | ||
|
||
## Enable Publishing | ||
|
||
1. Add your new repository to the repositories with access to [`NPM_PUBLISH_TOKEN` org level secret](https://github.com/organizations/reside-eng/settings/secrets/actions/NPM_PUBLISH_TOKEN) | ||
1. Create a PR removing `if: ${{ false }}` from release workflow | ||
1. Merge above mentioned PR to create first release - this will take a while since all PRs up until this first release will be marked as released by semantic-release | ||
|
||
[npm-image]: https://img.shields.io/npm/v/@side/template-library.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/@side/template-library | ||
[build-status-image]: https://img.shields.io/github/workflow/status/reside-eng/template-library/Release?style=flat-square | ||
[build-status-url]: https://github.com/reside-eng/template-library/actions | ||
[license-image]: https://img.shields.io/npm/l/@side/template-library.svg?style=flat-square | ||
[license-url]: https://github.com/reside-eng/template-library/blob/main/LICENSE | ||
## Use | ||
|
||
An artifact should be uploaded during the verify stage so that base can be set on closed event of the PR: | ||
|
||
**verify.yml** | ||
|
||
```yaml | ||
name: Verify | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
concurrency: | ||
group: verify-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ inputs.GIT_REF }} | ||
|
||
- name: Use Node.js ${{ inputs.NODE_VERSION }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ inputs.NODE_VERSION }} | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Verify lint | ||
run: yarn lint | ||
|
||
- name: Test app | ||
run: yarn test:cov | ||
|
||
# Used in merge-main.yml workflow to upload base branch coverage once merged | ||
# NOTE: Temporary - planned to be replaced by custom workflow in workflow-templates | ||
- name: Upload coverage artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: coverage-${{ github.event.pull_request.head.sha }} | ||
path: coverage/lcov.info | ||
``` | ||
**merge-main.yml** | ||
```yaml | ||
name: Merge to main | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
promote-deploy-prod: | ||
name: promote-deploy-prod | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ inputs.GIT_REF }} | ||
|
||
- name: Use Node.js ${{ inputs.NODE_VERSION }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ inputs.NODE_VERSION }} | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Verify lint | ||
run: yarn lint | ||
|
||
- name: Test app | ||
run: yarn test:cov | ||
|
||
# Download coverage artifact from verify.yml workflow and send as base to Coveralls | ||
- name: Upload base coverage to Coveralls | ||
uses: reside-eng/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
coveralls-token: ${{ secrets.COVERALLS_API_TOKEN }} | ||
``` | ||
## Inputs | ||
| name | required | default | description | | ||
| ------------------------ | -------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| github-token | `true` | `undefined` | GITHUB_TOKEN secret (for authentication with Github API) | | ||
| coveralls-token | `true` | `undefined` | Coveralls API token | | ||
| base-branch | `false` | `pull_request.head.ref \|\| 'main'` | Base branch (defaults to pull_request.head.ref falling back to "main") | | ||
| coverage-artifact-name | `false` | `'coverage'` | Name of coverage artifact (useful for multiple artifacts). NOTE: Each workflow run has it's own artifacts, so name only has to be unique compared to orther artifacts in the single workflow run. | | ||
| lcov-path | `false` | `'coverage/lcov.info'` | Path to lcov.info file | | ||
| upload-workflow-filename | `false` | `'verify.yml'` | Filename of workflow which uploaded coverage artifact | | ||
|
||
[build-status-image]: https://github.com/reside-eng/upload-coverage-base-action/actions/workflows/release.yml/badge.svg | ||
[build-status-url]: https://github.com/reside-eng/upload-coverage-base-action/actions | ||
[license-image]: https://img.shields.io/npm/l/@side/upload-coverage-base-action.svg?style=flat-square | ||
[license-url]: https://github.com/reside-eng/upload-coverage-base-action/blob/main/LICENSE | ||
[code-style-image]: https://img.shields.io/badge/code%20style-airbnb-blue.svg?style=flat-square | ||
[code-style-url]: https://github.com/airbnb/javascript | ||
[semantic-release-icon]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: 'Upload Coverage Base Action' | ||
description: 'Custom github action for uploading base branch coverage on pull_request close event (instead of default branch push)' | ||
inputs: | ||
github-token: | ||
description: 'GITHUB_TOKEN secret (for authentication with Github API)' | ||
required: true | ||
coveralls-token: | ||
description: 'Coveralls API token' | ||
required: true | ||
base-branch: | ||
description: 'Base branch (defaults to pull_request.head.ref falling back to "main")' | ||
required: false | ||
lcov-path: | ||
description: 'Path to lcov.info file' | ||
default: 'coverage/lcov.info' | ||
required: false | ||
coverage-artifact-name: | ||
description: > | ||
'Name of coverage artifact (useful for multiple artifacts). NOTE: Each workflow run has it's own artifacts, so name only has to be unique compared to orther artifacts in the single workflow run.' | ||
default: 'coverage' | ||
required: false | ||
upload-workflow-filename: | ||
description: 'Filename of workflow which uploaded coverage artifact' | ||
default: 'verify.yml' | ||
required: false | ||
runs: | ||
using: 'node16' | ||
main: 'dist/index.js' | ||
post-if: 'success()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.