-
Notifications
You must be signed in to change notification settings - Fork 0
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
81c47fc
commit c4c2bb0
Showing
403 changed files
with
21,287 additions
and
98,710 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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
name: CI | ||
|
||
on: | ||
# We use a `vX.Y` branch naming convention for our "main" branches, so we'll target pushes against those (including | ||
# merged PRs) | ||
push: | ||
branches: | ||
- v* | ||
- ci-test* | ||
# Additionally, we'll target PR updates so that CI runs against open PRs | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
# Finally, we'll allow the workflow to be triggered manually | ||
workflow_dispatch: | ||
|
||
# Only one run at a time per ref | ||
concurrency: | ||
group: ci-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
|
||
## | ||
## PREPARE | ||
## | ||
|
||
get-deploy-env: | ||
runs-on: ubuntu-latest | ||
# Necessary for nrwl/nx-set-shas | ||
permissions: | ||
contents: 'read' | ||
actions: 'read' | ||
outputs: | ||
affected-shas-base: ${{ steps.get-affected-sha-spread.outputs.base }} | ||
affected-shas-head: ${{ steps.get-affected-sha-spread.outputs.head }} | ||
pnpmFilter: ${{ steps.get-pnpm-params.outputs.pnpmFilter }} | ||
pnpmIgnorePattern: ${{ steps.get-pnpm-params.outputs.pnpmIgnorePattern }} | ||
allAppsJson: ${{ steps.get-all-pkgs.outputs.allAppsJson }} | ||
allLibsJson: ${{ steps.get-all-pkgs.outputs.allLibsJson }} | ||
affectedAppsJson: ${{ steps.get-affected-pkgs.outputs.affectedAppsJson }} | ||
affectedLibsJson: ${{ steps.get-affected-pkgs.outputs.affectedLibsJson }} | ||
deployable: ${{ steps.is-deployable.outputs.deployable }} | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Output some initial variables that we'll need later | ||
- name: Initial Vars | ||
id: initial-vars | ||
run: | | ||
# Replace this with 'v0.6.x' or another branch to simulate a CI run on that branch | ||
REFNAME=$GITHUB_REF_NAME | ||
#REFNAME=v0.7.x | ||
echo "REFNAME=$REFNAME" | ||
echo "REFNAME=$REFNAME" >> $GITHUB_ENV | ||
# TODO: Implement more complex handling of default branch | ||
BASEBRANCH="$(echo "$REFNAME" | grep -q '^v[0-9]+]\.' && echo $REFNAME || echo v0.7.x)" | ||
echo "BASEBRANCH=$BASEBRANCH" | ||
echo "BASEBRANCH=$BASEBRANCH" >> $GITHUB_ENV | ||
PNPM_VERSION="$(jq -r '.engines.pnpm' package.json)" | ||
echo "PNPM_VERSION=$PNPM_VERSION" | ||
echo "PNPM_VERSION=$PNPM_VERSION" >> $GITHUB_OUTPUT | ||
# Output some info for debugging purposes | ||
- name: Output Versions for Debugging | ||
run: | | ||
echo "effective branch: $REFNAME" | ||
echo "git: $(git --version)" | ||
echo "jq: $(jq --version)" | ||
echo "docker: $(docker --version 2>/dev/null)" | ||
# Install pnpm (we don't need the whole node setup and all the deps, so we're just doing a simple pnpm install here) | ||
- name: Install pnpm | ||
run: npm i -g pnpm@${{ steps.initial-vars.outputs.PNPM_VERSION }} | ||
|
||
# This is what allows us not to have to run our linting and testing against all of our code | ||
- name: Determine the spread of affected commits | ||
id: get-affected-sha-spread | ||
uses: nrwl/nx-set-shas@v4 | ||
with: | ||
main-branch-name: ${{ env.BASEBRANCH }} | ||
|
||
# Use our current info to get a pnpm filter and ignore pattern to use in future commands, as well as a list of | ||
# affected apps and libs | ||
- name: Get pnpm params | ||
id: get-pnpm-params | ||
run: ./.github/workflows/get-pnpm-params.sh | ||
- name: Get list of all packages from the repo | ||
id: get-all-pkgs | ||
run: ./.github/workflows/get-all-pkgs.sh | ||
- name: Get lists of affected libs and apps | ||
id: get-affected-pkgs | ||
run: ./.github/workflows/get-affected-pkgs.sh | ||
env: | ||
hasTopLevelChanges: ${{ steps.get-pnpm-params.outputs.hasTopLevelChanges }} | ||
pnpmFilter: ${{ steps.get-pnpm-params.outputs.pnpmFilter }} | ||
pnpmIgnorePattern: ${{ steps.get-pnpm-params.outputs.pnpmIgnorePattern }} | ||
allAppsJson: ${{ steps.get-all-pkgs.outputs.allAppsJson }} | ||
allLibsJson: ${{ steps.get-all-pkgs.outputs.allLibsJson }} | ||
|
||
# Finally, determine whether the current branch is deployable | ||
- name: Determine whether the current branch is deployable | ||
id: is-deployable | ||
run: | | ||
deployable="$(echo "$REFNAME" | grep -Eq '^v[0-9]+\..+$' && [ '${{ steps.get-affected-pkgs.outputs.affectedAppsJson }}' != '[]' ] && echo "true" || echo "false")" | ||
echo "deployable=$deployable" | ||
echo "deployable=$deployable" >> $GITHUB_OUTPUT | ||
## | ||
## Run linting/typechecks/tests | ||
## | ||
|
||
check: | ||
needs: [get-deploy-env] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: wymp/devops/actions/setup-node-pnpm@v1 | ||
|
||
- name: ESLint Cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: eslint-cache-${{ hashFiles('libs/**/*', 'apps/**/*', 'pnpm-lock.yaml') }} | ||
restore-keys: | | ||
eslint-cache- | ||
path: | | ||
./apps/*/node_modules/.cache/eslint-cache | ||
./libs/*/node_modules/.cache/eslint-cache | ||
- name: Jest Cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: jest-cache-${{ env.BRANCH }} | ||
restore-keys: | | ||
jest-cache- | ||
path: | | ||
/tmp/jest_* | ||
- name: Lint, Typecheck and Test | ||
run: | | ||
pnpm \ | ||
--parallel \ | ||
--filter="${{ needs.get-deploy-env.outputs.pnpmFilter }}" \ | ||
--changed-files-ignore-pattern="${{ needs.get-deploy-env.outputs.pnpmIgnorePattern }}" \ | ||
check |
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,59 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Expects: | ||
# | ||
# * to be run from repo root | ||
# * for repo to be checked out | ||
# * to have pnpm installed | ||
# * to have env: | ||
# * hasTopLevelChanges | ||
# * allAppsJson | ||
# * allLibsJson | ||
# * pnpmFilter | ||
# * pnpmIgnorePattern | ||
# | ||
# Outputs: | ||
# | ||
# * affectedAppsJson | ||
# * affectedLibsJson | ||
|
||
if [ -n "$hasTopLevelChanges" ]; then | ||
|
||
affectedAppsJson="$allAppsJson" | ||
affectedLibsJson="$allLibsJson" | ||
|
||
else | ||
|
||
affected="$(pnpm --filter="$pnpmFilter" --changed-files-ignore-pattern="$pnpmIgnorePattern" exec pwd | grep -v 'No projects matched' | tr '\n' ' ')" | ||
|
||
|
||
for d in $affected; do | ||
pkg="$(basename "$d")" | ||
if echo "$d" | grep -q /apps/; then | ||
if [ -z "$affectedAppsJson" ]; then | ||
affectedAppsJson='"'$pkg'"' | ||
else | ||
affectedAppsJson="${affectedAppsJson},"'"'$pkg'"' | ||
fi | ||
|
||
else | ||
if [ -z "$affectedLibsJson" ]; then | ||
affectedLibsJson='"'$pkg'"' | ||
else | ||
affectedLibsJson="${affectedLibsJson},"'"'$pkg'"' | ||
fi | ||
fi | ||
|
||
done | ||
|
||
affectedAppsJson="[$affectedAppsJson]" | ||
affectedLibsJson="[$affectedLibsJson]" | ||
|
||
fi | ||
|
||
echo "affectedAppsJson=$affectedAppsJson" | ||
echo "affectedAppsJson=$affectedAppsJson" >> $GITHUB_OUTPUT | ||
echo "affectedLibsJson=$affectedLibsJson" | ||
echo "affectedLibsJson=$affectedLibsJson" >> $GITHUB_OUTPUT |
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,42 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Expects: | ||
# | ||
# * to be run from repo root | ||
# * for repo to be checked out | ||
# | ||
# Outputs: | ||
# | ||
# * allAppsJson | ||
# * allLibsJson | ||
|
||
allAppsJson= | ||
allLibsJson= | ||
|
||
for d in libs/* apps/*; do | ||
|
||
pkg="$(basename "$d")" | ||
|
||
if echo "$d" | grep -q apps/; then | ||
if [ -z "$allAppsJson" ]; then | ||
allAppsJson='"'$pkg'"' | ||
else | ||
allAppsJson="${allAppsJson},"'"'$pkg'"' | ||
fi | ||
|
||
else | ||
if [ -z "$allLibsJson" ]; then | ||
allLibsJson='"'$pkg'"' | ||
else | ||
allLibsJson="${allLibsJson},"'"'$pkg'"' | ||
fi | ||
fi | ||
|
||
done | ||
|
||
echo "allAppsJson=[$allAppsJson]" | ||
echo "allAppsJson=[$allAppsJson]" >> $GITHUB_OUTPUT | ||
echo "allLibsJson=[$allLibsJson]" | ||
echo "allLibsJson=[$allLibsJson]" >> $GITHUB_OUTPUT |
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,35 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Expects: | ||
# | ||
# * to be run from repo root | ||
# * for repo to be checked out | ||
# * to have env: | ||
# * NX_BASE | ||
# | ||
# Outputs: | ||
# | ||
# * hasTopLevelChanges | ||
# * pnpmFilter | ||
# * pnpmIgnorePattern | ||
|
||
|
||
# Determine if any important top-level files have changed that would require a full re-deploy of everything | ||
hasTopLevelChanges="$( | ||
git diff --name-only "$NX_BASE" | \ | ||
grep -qE '^(\.github|\.jest|deploy/dockerfile.+|scripts|\.dockerignore|\.npmrc|\.eslint\.config\.js|package\.json|pnpm-lock|pnpm-workspace|tsconfig)' && \ | ||
echo 1 || \ | ||
echo "" | ||
)" | ||
|
||
pnpmFilter="$([ -n "$hasTopLevelChanges" ] && echo "*" || echo "...[$NX_BASE]")" | ||
pnpmIgnorePattern="**/tests,**/*.md" | ||
|
||
echo "hasTopLevelChanges=$hasTopLevelChanges" | ||
echo "hasTopLevelChanges=$hasTopLevelChanges" >> $GITHUB_OUTPUT | ||
echo "pnpmFilter=$pnpmFilter" | ||
echo "pnpmFilter=$pnpmFilter" >> $GITHUB_OUTPUT | ||
echo "pnpmIgnorePattern=$pnpmIgnorePattern" | ||
echo "pnpmIgnorePattern=$pnpmIgnorePattern" >> $GITHUB_OUTPUT |
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,3 +1,5 @@ | ||
node_modules | ||
*.sw[op] | ||
dist | ||
tmp | ||
*.tsbuildinfo |
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,7 @@ | ||
module.exports = { | ||
transform: { | ||
"^.+\\.(ts|tsx)$": ["ts-jest", { | ||
tsconfig: "<rootDir>/tsconfig.test.json", | ||
}], | ||
}, | ||
} |
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,13 @@ | ||
/** | ||
* This config is intended to contain only _global_ config options. Certain options (such as `transform` and others) are | ||
* considered project configs and must be defined either in `.jest/common.js` or in the project's own config file. | ||
* @type {import('jest').Config} | ||
*/ | ||
const config = { | ||
// Run tests from one or more projects | ||
projects: [ | ||
"<rootDir>/../libs/*", | ||
], | ||
}; | ||
|
||
module.exports = config; |
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,3 +1,2 @@ | ||
*.md | ||
docs | ||
*/docs |
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,6 +1,22 @@ | ||
Simple Interfaces (Typescript) | ||
=========================================================================== | ||
|
||
This is a monorepo for developing simple typescript interfaces and related artifacts. For more | ||
information, see [ts-simple-interfaces](packages/ts-simple-interfaces/) and | ||
[ts-simple-interfaces-testing](packages/ts-simple-interfaces-testing/). | ||
This is a monorepo for developing simple typescript interfaces, implementations of those interfaces, and related | ||
artifacts. For more information, see [ts-simple-interfaces](packages/ts-simple-interfaces/README.md) and | ||
[ts-simple-interfaces-testing](packages/ts-simple-interfaces-testing/README.md). | ||
|
||
|
||
## Development | ||
|
||
**This monorepo is based on [@wymp/ts-monorepo-poc](https://github.com/wymp/ts-monorepo-poc). See that project for | ||
documentation on the general ideas.** | ||
|
||
|
||
### Quickstart | ||
|
||
_This monorepo uses `pnpm`._ | ||
|
||
* Install: `pnpm i` | ||
* Build: `pnpm build` | ||
* Format: `pnpm format` | ||
* Publish: `pnpm version:bump`, then commit and tag, then `pnpm publish:all` |
Oops, something went wrong.