Skip to content

Commit

Permalink
Merge branch 'main' into feature/text-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodeTherapy committed Sep 4, 2023
2 parents 7e03a6d + 0b919eb commit a092727
Show file tree
Hide file tree
Showing 34 changed files with 13,655 additions and 37,244 deletions.
44 changes: 44 additions & 0 deletions .github/actions/npm-install-build-and-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: NPM Install, Build, and Cache
description: NPM Install Dependencies, NPM Run Build, and Cache Dependencies & Artifacts

outputs:
npm-deps-cache-hit:
description: "Whether or not the npm dependencies are cached"
value: ${{ steps.cache-npm-deps.outputs.cache-hit }}

runs:
using: "composite"
steps:
- name: Set up nodejs
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm

- name: Cache NPM dependencies
uses: actions/cache@v3
id: cache-npm-deps
with:
path: |
node_modules
~/.cache
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-npm-deps.outputs.cache-hit != 'true'
shell: bash
run: npm ci

- name: Build
shell: bash
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
packages/**/build/*
e2e-tests/build/*
if-no-files-found: error
25 changes: 25 additions & 0 deletions .github/actions/retrieve-deps-and-build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Retrieve Dependencies and Build Artifacts
description: Retrieve cached NPM Install Dependencies and NPM Run Build Artifacts

runs:
using: "composite"
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts

- name: Set up nodejs
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm

- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: |
node_modules
~/.cache
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
125 changes: 103 additions & 22 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,139 @@ permissions:
checks: write

jobs:
main:
name: Main
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- uses: actions/cache@v3
with:
path: |
~/.cache
key: ${{ runner.os }}
- name: "NPM Install, Build, and Cache"
id: npm-install-build-and-cache
uses: ./.github/actions/npm-install-build-and-cache

- name: Set up nodejs
uses: actions/setup-node@v3
test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
node-version-file: ".nvmrc"
cache: npm

- name: Install dependencies
run: npm ci
persist-credentials: false

- name: Build
run: npm run build
- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Test
run: npm run test-all

type-check:
name: Type Check
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Type Check
run: npm run type-check-all

lint:
name: Lint
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Lint
run: npm run lint-all

summary:
name: Summary
needs: [build, test, type-check, lint]
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "Build: ${{ needs.build.result }}"
echo "Test: ${{ needs.test.result }}"
echo "Type Check: ${{ needs.type-check.result }}"
echo "Lint: ${{ needs.lint.result }}"
publish-experimental-packages:
name: Publish Experimental Packages
needs: summary
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Publish
run: |
# Set up git user for lerna to create a local commit with
git config --global user.email "[email protected]"
git config --global user.name "lerna-ci-mml"
# Set up npm auth token from secret for publishing
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
# Attempt to publish at the current version - this will skip if the version already exists
echo "Attempting to publishing latest version"
./node_modules/.bin/lerna publish from-package --no-private --dist-tag latest --ignore-scripts --ignore-changes --no-push --yes
# Publish the current commit as an "experimental" version
version="0.0.0-experimental-$(git rev-parse --short HEAD)-$(date +'%Y%m%d')"
echo "Publishing experimental version $version"
./node_modules/.bin/lerna publish $version --no-private --dist-tag experimental --ignore-scripts --ignore-changes --no-push --yes
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}


publish-release-packages:
name: Publish Packages
environment: package-release
needs: summary
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Publish
run: |
# Set up git user for lerna to create a local commit with
git config --global user.email "[email protected]"
git config --global user.name "lerna-ci-mml"
# Set up npm auth token from secret for publishing
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
# Attempt to publish at the current version - this will skip if the version already exists
echo "Attempting to publishing latest version"
./node_modules/.bin/lerna publish from-package --no-private --dist-tag latest --ignore-scripts --ignore-changes --no-push --yes
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
74 changes: 56 additions & 18 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull Request Test
name: PR

on:
pull_request:
Expand All @@ -11,40 +11,78 @@ permissions:
checks: write

jobs:
pr:
name: Pull Request Test
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- uses: actions/cache@v3
with:
path: |
~/.cache
key: ${{ runner.os }}
- name: "NPM Install, Build, and Cache"
id: npm-install-build-and-cache
uses: ./.github/actions/npm-install-build-and-cache

- name: Set up nodejs
uses: actions/setup-node@v3
test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
node-version-file: ".nvmrc"
cache: npm

- name: Install dependencies
run: npm ci
persist-credentials: false

- name: Build
run: npm run build
- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Test
run: npm run test-all

type-check:
name: Type Check
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Type Check
run: npm run type-check-all

lint:
name: Lint
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: "Retrieve Dependencies and Build Artifacts"
id: retrieve-deps-and-build
uses: ./.github/actions/retrieve-deps-and-build

- name: Lint
run: npm run lint-all


summary:
name: Summary
needs: [build, test, type-check, lint]
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "Build: ${{ needs.build.result }}"
echo "Test: ${{ needs.test.result }}"
echo "Type Check: ${{ needs.type-check.result }}"
echo "Lint: ${{ needs.lint.result }}"
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v18.16.0
10 changes: 6 additions & 4 deletions check-node-version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { readFileSync } = require("fs");
const { resolve } = require("path");
#!/usr/bin/env node

import { readFileSync } from "fs";
import { resolve } from "path";

let nvmrc;
try {
Expand All @@ -12,8 +14,8 @@ try {
const currentVersion = process.version.trim();
const nvmrcVersion = nvmrc.trim();

if (currentVersion.startsWith(nvmrcVersion)) {
console.log(`nvmrc node version (${nvmrcVersion}) matches: ${currentVersion}`);
if (currentVersion === nvmrcVersion) {
console.log(`Node version matches: ${currentVersion}`);
} else {
console.error(`Node version mismatch (${currentVersion} != ${nvmrcVersion}).`);
console.log(`Run 'nvm install ${nvmrcVersion}' to resolve.`);
Expand Down
4 changes: 2 additions & 2 deletions example/server/build.js → example/server/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import esbuild from "esbuild";
import * as esbuild from "esbuild";

const buildMode = "--build";
const watchMode = "--watch";
Expand All @@ -14,7 +14,7 @@ if (args.length !== 1) {

const mode = args[0];

const buildOptions = {
const buildOptions: esbuild.BuildOptions = {
entryPoints: ["src/index.ts"],
outdir: "./build",
bundle: true,
Expand Down
Loading

0 comments on commit a092727

Please sign in to comment.