diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e7c5c60..26e977b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,19 +6,73 @@ on: pull_request: jobs: - publish: + setup: 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: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 id: node-setup with: node-version: 16 - - name: Install - run: yarn + - uses: actions/cache@v2 + 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 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 env: DICTIONARY_TAG: rev_22-01-2022-22-04 @@ -26,6 +80,31 @@ jobs: run: | gh release download --repo mcataford/words ${{ env.DICTIONARY_TAG }} 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 if: ${{ github.ref != 'refs/heads/main' }} id: preview-deploy @@ -33,8 +112,8 @@ jobs: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} run: | - yarn netlify deploy > output.log - echo "::set-output name=draft-url::$(grep 'Website Draft URL' output.log)" + yarn netlify deploy --json | jq '.deploy_url' -r > deploy_url.txt + echo "::set-output name=draft-url::$(cat deploy_url.txt)" - name: Report if: ${{ github.ref != 'refs/heads/main' }} uses: actions/github-script@v2 diff --git a/package.json b/package.json index 820fd12..d6a1f74 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "start": "yarn netlify dev", "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" }, "devDependencies": { diff --git a/packages/frontend/src/index.ts b/packages/frontend/src/index.ts index 8d08f59..571c5ac 100644 --- a/packages/frontend/src/index.ts +++ b/packages/frontend/src/index.ts @@ -29,12 +29,12 @@ function draw(state: GameState) { cellTable.id = 'game-grid' for (let height = 0; height < state.puzzleSize; height++) { const row = document.createElement('div') - row.className = "row" + row.className = 'row' const currentWord = letters.length > 0 ? letters.shift() : [] for (let width = 0; width < state.puzzleSize; width++) { const cell = document.createElement('div') - cell.className = "cell" + cell.className = 'cell' if (width < currentWord.length) { const cellData = currentWord[width] diff --git a/script/buildDictionary.ts b/script/buildDictionary.ts index 92fafe5..e8b97ee 100644 --- a/script/buildDictionary.ts +++ b/script/buildDictionary.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { promises as fs } from 'fs' import * as sqlite3 from 'sqlite3'