ci: parallelizes build tasks (#4)

* ci: parallelizes build tasks

* fix: duplicated attr

* ci: do not yarn if cache

* fix: artifact pull path

* chore: lint

* build: lint script

* ci: linting step

* ci: url extraction for PR comment
This commit is contained in:
Marc Cataford 2022-01-25 23:21:59 -05:00 committed by GitHub
parent 6e2569f75e
commit e501f01dfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 8 deletions

View file

@ -6,19 +6,73 @@ on:
pull_request: pull_request:
jobs: jobs:
publish: setup:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Publish name: Setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: actions/cache@v2
id: dep-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install
if: steps.dep-cache.outputs.cache-hit != 'true'
run: yarn
lint:
runs-on: ubuntu-latest
name: Lint
needs: setup
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
id: node-setup id: node-setup
with: with:
node-version: 16 node-version: 16
- name: Install - uses: actions/cache@v2
run: yarn with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Lint
run: yarn lint
build-frontend:
runs-on: ubuntu-latest
name: Build frontend
needs: setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Build - name: Build
run: yarn build:frontend run: yarn build:frontend
- uses: actions/upload-artifact@v2
with:
name: frontend-dist
path: dist
build-dictionary:
runs-on: ubuntu-latest
name: Build dictionary
needs: setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Build dictionary - name: Build dictionary
env: env:
DICTIONARY_TAG: rev_22-01-2022-22-04 DICTIONARY_TAG: rev_22-01-2022-22-04
@ -26,6 +80,31 @@ jobs:
run: | run: |
gh release download --repo mcataford/words ${{ env.DICTIONARY_TAG }} gh release download --repo mcataford/words ${{ env.DICTIONARY_TAG }}
yarn ts-node script/buildDictionary.ts yarn ts-node script/buildDictionary.ts
- uses: actions/upload-artifact@v2
with:
name: dictionary
path: puzzles.sqlite
publish:
runs-on: ubuntu-latest
name: Publish
needs: [lint, build-frontend, build-dictionary]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- uses: actions/download-artifact@v2
with:
name: frontend-dist
path: dist
- uses: actions/download-artifact@v2
with:
name: dictionary
- name: Deploy preview - name: Deploy preview
if: ${{ github.ref != 'refs/heads/main' }} if: ${{ github.ref != 'refs/heads/main' }}
id: preview-deploy id: preview-deploy
@ -33,8 +112,8 @@ jobs:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: | run: |
yarn netlify deploy > output.log yarn netlify deploy --json | jq '.deploy_url' -r > deploy_url.txt
echo "::set-output name=draft-url::$(grep 'Website Draft URL' output.log)" echo "::set-output name=draft-url::$(cat deploy_url.txt)"
- name: Report - name: Report
if: ${{ github.ref != 'refs/heads/main' }} if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/github-script@v2 uses: actions/github-script@v2

View file

@ -9,6 +9,7 @@
"scripts": { "scripts": {
"start": "yarn netlify dev", "start": "yarn netlify dev",
"lint:fix": "yarn eslint packages/**/src/**/*.(t|j)s script/*.(t|j)s --fix", "lint:fix": "yarn eslint packages/**/src/**/*.(t|j)s script/*.(t|j)s --fix",
"lint": "yarn eslint packages/**/src/**/*.(t|j)s script/*.(t|j)s",
"build:frontend": "yarn parcel build packages/frontend/src/index.html --dist-dir ./dist" "build:frontend": "yarn parcel build packages/frontend/src/index.html --dist-dir ./dist"
}, },
"devDependencies": { "devDependencies": {

View file

@ -29,12 +29,12 @@ function draw(state: GameState) {
cellTable.id = 'game-grid' cellTable.id = 'game-grid'
for (let height = 0; height < state.puzzleSize; height++) { for (let height = 0; height < state.puzzleSize; height++) {
const row = document.createElement('div') const row = document.createElement('div')
row.className = "row" row.className = 'row'
const currentWord = letters.length > 0 ? letters.shift() : [] const currentWord = letters.length > 0 ? letters.shift() : []
for (let width = 0; width < state.puzzleSize; width++) { for (let width = 0; width < state.puzzleSize; width++) {
const cell = document.createElement('div') const cell = document.createElement('div')
cell.className = "cell" cell.className = 'cell'
if (width < currentWord.length) { if (width < currentWord.length) {
const cellData = currentWord[width] const cellData = currentWord[width]

View file

@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { promises as fs } from 'fs' import { promises as fs } from 'fs'
import * as sqlite3 from 'sqlite3' import * as sqlite3 from 'sqlite3'