Skip to content

Commit

Permalink
split ci into multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed Jan 12, 2024
1 parent eaaa12d commit f037c41
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[{package.json,bower.json,.github/workflows/*.yml}]
[{package.json,bower.json,.github/**/*.yml}]

indent_size = 2
34 changes: 34 additions & 0 deletions .github/actions/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Install Project"
description: "Installs node, npm, and dependencies"
inputs:
node-version:
description: "Node.js version"
required: true
default: "18"
npm-version:
description: "npm version"
required: true
default: "8"
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install npm
run: npm install -g npm@${{ inputs.npm-version }}
- name: Cache Dependencies
id: node-modules-cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci
19 changes: 19 additions & 0 deletions .github/actions/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Test Project"
description: "Runs unit tests"
runs:
using: "composite"
steps:
- name: Type Tests
run: npm run test:types

- name: Unit Tests
run: xvfb-run --auto-servernum npm run coverage
env:
NODE_ENV: production

- name: Upload Unit Test Images
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: pr_uploads
path: .pr_uploads/
43 changes: 43 additions & 0 deletions .github/actions/upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "S3 Upload"
description: "Uploads files to s3 bucket"
inputs:
type:
description: "Type of upload"
required: true
default: "Non-Tag"
runs:
using: "composite"
steps:
- name: Extract Branch Name
id: branch_name
if: github.event_name == 'push'
run: echo BRANCH_NAME=${GITHUB_REF/refs\/heads\//} >> $GITHUB_OUTPUT
# Examples:
# 1) PR feature/acme merged into dev
# 2) branch A merged into branch B
# 3) branch A pushed directly to git
- name: Deploy Non-Tag Branches
uses: jakejarvis/s3-sync-action@master
if: ${{ inputs.type }} == "Non-Tag" && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=60"
env:
DEST_DIR: ${{ steps.branch_name.outputs.BRANCH_NAME }}

# Release is published and deployed into s3://bucket-name/v5.22/
- name: Deploy Released Branches
uses: jakejarvis/s3-sync-action@master
if: ${{ inputs.type }} == "Release-Branch" && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=2592000"
env:
DEST_DIR: ${{ github.event.release.tag_name }}

# Same release from previous deployed into s3://bucket-name/release/
- name: Deploy Latest Release
uses: jakejarvis/s3-sync-action@master
if: ${{ inputs.type }} == "Release" && github.event.release.prerelease == false && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=1209600"
env:
DEST_DIR: 'release'
107 changes: 0 additions & 107 deletions .github/workflows/nodejs.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test (Pull Request)

on:
pull_request:
branches: [ '**' ]

jobs:
build:
runs-on: ubuntu-4-cores
steps:
- name: Setup project
uses: ./.github/actions/setup
with:
node-version: '18'
npm-version: '8'

- name: Test Project
uses: ./.github/actions/unit

- name: Test Build
run: npm run dist
39 changes: 39 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Upload (Push)

on:
push:
branches: [ '**' ]

jobs:
build:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || '' }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || '' }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: '.s3_uploads'
runs-on: ubuntu-latest
steps:
- name: Setup project
uses: ./.github/actions/setup-project
with:
node-version: '18'
npm-version: '8'

- name: Extract Branch Name
id: branch_name
if: github.event_name == 'push'
run: echo BRANCH_NAME=${GITHUB_REF/refs\/heads\//} >> $GITHUB_OUTPUT

- name: Build for Distribution
run: npm run dist

# Examples:
# 1) PR feature/acme merged into dev
# 2) branch A merged into branch B
# 3) branch A pushed directly to git
- name: Deploy Non-Tag Branches
uses: ./.github/actions/upload
with:
type: "Non-Tag"
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
release:
types: [ published ]

jobs:
build:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || '' }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || '' }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: '.s3_uploads'
runs-on: ubuntu-4-cores
steps:
- name: Setup project
uses: ./.github/actions/setup
with:
node-version: '18'
npm-version: '8'

# Run unit and visual tests
- name: Test Project
uses: ./.github/actions/unit

# Build the project
- name: Test Build
run: npm run dist

# Append assets to releases
- name: Upload Assets to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
./dist/**/*
# Release is published and deployed into s3://bucket-name/v5.22/
- name: Deploy Released Branches
if: github.event_name == 'release' && env.AWS_ACCESS_KEY_ID != ''
uses: ./.github/actions/upload
with:
type: "Release-Branch"

# Same release from previous deployed into s3://bucket-name/release/
- name: Deploy Latest Release
if: github.event_name == 'release' && github.event.release.prerelease == false && env.AWS_ACCESS_KEY_ID != ''
uses: ./.github/actions/upload
with:
type: "Release"

# Publish to NPM
- name: Publish Latest Release
if: github.event_name == 'release' && github.event.release.prerelease == false && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci

# Publish to NPM with prerelease dist-tag
- name: Publish Latest Prerelease
if: github.event_name == 'release' && github.event.release.prerelease && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci -- --tag prerelease-v8
20 changes: 0 additions & 20 deletions .github/workflows/trigger-website-build.yml

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"clean:index": "rimraf \"src/*/**/index.ts\" --glob",
"clean:uploads": "rimraf .pr_uploads .s3_uploads --glob",
"prebuild": "npm run clean",
"build": "run-s build:index test:types build:pkg build:rollup build:tsc build:dts",
"build": "run-s build:index build:pkg build:rollup build:tsc build:dts",
"build:rollup": "npx rollup -c",
"build:tsc": "tsc -p tsconfig.types.json",
"build:index": "ts-node --transpile-only ./scripts/index/index.ts",
Expand All @@ -36,7 +36,7 @@
"test:scene": "npx jest --silent --testPathPattern=tests/visual",
"test:scene:debug": "cross-env DEBUG_MODE=1 npx jest --testPathPattern=tests/visual",
"test:types": "tsc --noEmit",
"coverage": "npm run test:unit --coverage --maxWorkers=1 && npm run test:scene -- --maxWorkers=1",
"coverage": "npm run test:unit --coverage --watchAll=false --runInBand && npm run test:scene -- --watchAll=false --maxWorkers=50%",
"docs": "mkdirp out && npm run docs:webdoc",
"docs:webdoc": "webdoc -R README.md",
"docs:watch": "nodemon --watch \"./src/*\" --exec \"npm run docs\" -e ts",
Expand Down
4 changes: 2 additions & 2 deletions src/scene/sprite/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export class Sprite extends Container implements View
/**
* Helper function that creates a new sprite based on the source you provide.
* The source can be - frame id, image, video, canvas element, video element, texture
* @param {TextureSourceLike} source - Source to create texture from
* @param source - Source to create texture from
* @param [skipCache] - Whether to skip the cache or not
* @returns The newly created sprite
*/
public static from(source: TextureSourceLike, skipCache = false): Sprite
public static from(source: Texture | TextureSourceLike, skipCache = false): Sprite
{
if (source instanceof Texture)
{
Expand Down

0 comments on commit f037c41

Please sign in to comment.