Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Split CI into discrete jobs (#981)
sarayourfriend5b24e6fd3499
diff --git a/.github/actions/setup-node-env/action.yml b/.github/actions/setup-node-env/action.ymlnew file mode 100644index 000000000..cbb915f43--- /dev/null+++ b/.github/actions/setup-node-env/action.yml@@ -0,0 +1,39 @@+name: openverse-frontend/setup-node-env+description: Setup the Node.js environment including `pnpm` and dependencies++inputs:+ install:+ default: true+ description: Whether to install dependencies.++runs:+ using: "composite"+ steps:+ - uses: pnpm/[email protected]+ with:+ version: 6.30.1++ - name: Cache pnpm modules+ uses: actions/cache@v2+ with:+ path: ~/.pnpm-store+ key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}+ restore-keys: |+ ${{ runner.os }}-++ - uses: actions/[email protected]+ with:+ node-version: 16+ cache: pnpm+ cache-dependency-path: |+ pnpm-lock.yaml+ .npmrc++ - name: Install+ if: inputs.install+ shell: bash+ run: "pnpm install"++ - name: Get locales+ shell: bash+ run: "pnpm i18n:create-locales-list && pnpm i18n:update-locales && pnpm i18n:get-translations"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 80fdb89ac..f52119c29 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1,56 +1,103 @@-name: openverse-frontend-ci+name: CIon:push:- branches:- - main+ branches: -mainpull_request:- branches:- - main- - audiojobs:- ci:- name: Run CI tests+ types:+ name: Check typesruns-on: ubuntu-lateststeps:- uses: actions/checkout@v2- - name: Setup Node.js- uses: actions/setup-node@v1- with:- node-version: "16.13.0"-- - name: Cache Node.js modules- uses: actions/cache@v2- with:- path: ~/.pnpm-store- key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}- restore-keys: |- ${{ runner.os }}--- - uses: pnpm/[email protected]- with:- version: 6.24.0- run_install: |- - recursive: true- args: [--frozen-lockfile]-- - name: Run lint+ - uses: ./.github/actions/setup-node-env++ - name: Check types+ run: pnpm types++ lint:+ name: Lint files+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v2++ - uses: ./.github/actions/setup-node-env++ - name: ESLintrun: pnpm lint- - name: Run formatting test+ - name: Prettierrun: pnpm format:test- - name: Run tests- run: pnpm i18n:get-translations && pnpm test:unit+ i18n:+ name: Check translation files+ runs-on: ubuntu-latest- - name: Run Storybook smoke-test- run: pnpm storybook -- --ci --smoke-test+ steps:+ - uses: actions/checkout@v2++ - uses: ./.github/actions/setup-node-env++ - name: Check extracted strings+ run: pnpm vue-i18n-check++ - name: Check POT files are updated+ shell: bash+ run: |+ pnpm i18n:generate-pot+ exit $(git status -s -uno | wc -l)++ unit:+ name: Unit tests+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v2++ - uses: ./.github/actions/setup-node-env++ - name: Run unit tests+ run: pnpm test++ e2e:+ name: E2E tests+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v2++ - uses: ./.github/actions/setup-node-env- name: Install E2E browsersrun: pnpx playwright install- - name: Run E2E+ - name: Run E2E testsrun: pnpm e2e:ci++ storybook:+ name: Check Storybook build+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v2++ - uses: ./.github/actions/setup-node-env++ - name: Run Storybook smoke-test+ run: pnpm storybook -- --ci --smoke-test++ build:+ name: Check Nuxt build+ runs-on: ubuntu-latest++ steps:+ - uses: actions/checkout@v2++ - uses: ./.github/actions/setup-node-env++ - name: Run build+ run: pnpm builddiff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yamlindex a1f957ba3..c340b8b3c 100644--- a/.github/workflows/gh-pages.yaml+++ b/.github/workflows/gh-pages.yaml@@ -14,31 +14,7 @@ jobs:- name: Checkoutuses: actions/checkout@v2- # setup node.js environment and npm- - name: Setup Node environment- uses: actions/setup-node@v2- with:- node-version: '16.x'-- - name: Cache dependencies- uses: actions/cache@v2- with:- path: ~/.pnpm-store- key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}- restore-keys: |- ${{ runner.os }}--- - name: Setup pnpm- uses: pnpm/[email protected]- with:- version: 6.24.0- # Set this to false because we want to be able to skip installation if there is a cache hit in the next step- run_install: false-- # install dependencies only if the cache is not present- - name: Install dependencies- if: steps.cache-node-modules.outputs.cache-hit != 'true'- run: pnpm install --frozen-lockfile+ - uses: ./.github/actions/setup-node-env- name: Fetch translation filesrun: pnpm i18n:get-translationsdiff --git a/.github/workflows/pre-build.yaml b/.github/workflows/pre-build.yamldeleted file mode 100644index f54703514..000000000--- a/.github/workflows/pre-build.yaml+++ /dev/null@@ -1,56 +0,0 @@-# this workflow will try to lint and build a node.js application-#-# this is useful for stages that you require making sure everything is working-# properly before creating a container image to be pushed on the cloud-#-name: openverse/validate--on:- pull_request:-# push:-# branches:-# - 'main'-# - 'ci/*' # branches that follows the pattern ci/* can access this workflow too--jobs:- pre_build:- name: pre_build- runs-on: ubuntu-latest-- steps:- # download the source code into the runner- - name: checkout- uses: actions/checkout@v2-- # setup node.js environment and npm- - name: setup node environment- uses: actions/setup-node@v2- with:- node-version: '16.x'-- - name: cache dependencies- uses: actions/cache@v2- with:- path: ~/.pnpm-store- key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}- restore-keys: |- ${{ runner.os }}--- - uses: pnpm/[email protected]- with:- version: 6.24.0- # Set this to false because we want to be able to skip installation if there is a cache hit in the next step- run_install: false-- # install dependencies only if the cache is not present- - name: install dependencies- if: steps.cache-node-modules.outputs.cache-hit != 'true'- run: pnpm install --frozen-lockfile-- # run lint and syntax- - name: lint & syntax check- run: pnpm lint-- # run type checker- - name: typescript- run: pnpm typesdiff --git a/.lintstagedrc b/.lintstagedrcindex 7da10fb58..6b6f994b6 100644--- a/.lintstagedrc+++ b/.lintstagedrc@@ -2,10 +2,7 @@"*.{ts,js,vue}": ["eslint --fix"],- ".{ts,js,vue,json}": [- "prettier --write"- ],- "*.mdx": [+ "*.{ts,js,vue,json,yml,yaml,mdx}": ["prettier --write"]}diff --git a/src/locales/po-files/openverse.pot b/src/locales/po-files/openverse.potindex ae04cf7ff..665b9ade2 100644--- a/src/locales/po-files/openverse.pot+++ b/src/locales/po-files/openverse.pot@@ -4,7 +4,7 @@ msgid ""msgstr """Project-Id-Version: Openverse \n""Report-Msgid-Bugs-To: https://github.com/wordpress/openverse/issues \n"-"POT-Creation-Date: 2022-02-22T03:29:50+00:00\n"+"POT-Creation-Date: 2022-02-22T15:15:29+00:00\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"diff --git a/src/locales/scripts/json-to-pot.js b/src/locales/scripts/json-to-pot.jsindex be5e0a859..751392fea 100644--- a/src/locales/scripts/json-to-pot.js+++ b/src/locales/scripts/json-to-pot.js@@ -2,8 +2,21 @@ const json = require('../en.json')const fs = require('fs')const { createPotFile } = require('./json-pot-helpers')+const matchPotCreationDate = /^"POT-Creation-Date: .*\\n"$/gm+try {const fileName = process.cwd() + '/src/locales/po-files/openverse.pot'+ const existingPotFile = String(fs.readFileSync(fileName)).replace(+ matchPotCreationDate,+ ''+ )+ const potFile = createPotFile(json)++ if (existingPotFile === potFile.replace(matchPotCreationDate, '')) {+ console.log('No change detected in pot file, skipping write')+ return process.exit(0)+ }+fs.writeFileSync(fileName, createPotFile(json))console.log(`Successfully wrote pot file to ${fileName}`)} catch (err) {