Skip to content

Commit

Permalink
fix: improve packages compatibility + better testing (#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Aug 23, 2023
1 parent 66aec05 commit 2de9bac
Show file tree
Hide file tree
Showing 66 changed files with 9,089 additions and 6,971 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"*.js",
"**/lib",
"**/src/serviceWorker.ts",
"*.d.ts"
"*.d.ts",
"dist-e2e"
],
"extends": [
"eslint:recommended",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease-tolgee-5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- name: Set git globals
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- name: Create branch
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-examples-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
[
'react',
'next',
'next-app',
'vue',
'svelte',
'ngx',
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
'react',
'next',
'vue',
'next-app',
'svelte',
'ngx',
'react-i18next',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- name: Set git globals
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/report-intermittent-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- uses: actions/cache@v3
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- uses: actions/cache@v3
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- uses: actions/cache@v3
Expand Down
163 changes: 80 additions & 83 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,25 @@ name: Test

on:
pull_request:
push:
branches: [main]

jobs:
test:
name: 'Test'
prepare:
name: Prepare packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
run_install: false

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: .pnpm-store/v3
key: ${{ runner.os }}-pnpm-test-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-test-
token: '${{ secrets.TOLGEE_MACHINE_PAT }}'

- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-${{ github.job }}-${{ github.sha }}
restore-keys: |
turbo-${{ github.job }}-
- name: Install
run: pnpm install --no-frozen-lockfile

- name: Build all packages
run: pnpm build || pnpm build

- name: Test
run: pnpm run test

cypress-prepare:
name: 'Cypress prepare'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: '18'

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- uses: actions/cache@v3
Expand All @@ -72,27 +29,50 @@ jobs:
path: |
.pnpm-store/v3
~/.cache/Cypress
key: ${{ runner.os }}-pnpm-cypress-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-pnpm-prepare-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-cypress-
${{ runner.os }}-pnpm-prepare-
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-cypress-${{ github.sha }}
key: turbo-prepare-${{ github.job }}-${{ github.sha }}
restore-keys: |
turbo-cypress-
turbo-prepare-${{ github.job }}-
- name: Install
run: pnpm install --no-frozen-lockfile
- name: Create branch
run: git checkout -b test.$(git ls-files -s packages | git hash-object --stdin)

- name: Install root and packages dependencies
run: |
pnpm install --ignore-workspace
pnpm install --no-frozen-lockfile --filter='./packages/*'
- name: Update version with lerna
run: |
lerna version prerelease --yes --conventional-prerelease --preid test.$(git ls-files -s packages | git hash-object --stdin) --ignore-scripts \
--force-publish --no-push --no-git-tag-version --exact
- name: Set TOLGEE_UI_VERSION
run: |
echo "TOLGEE_UI_VERSION=$(pnpm run --silent ui-version)" >> $GITHUB_ENV
pnpm run --silent ui-version
- name: Build
run: pnpm build || pnpm build
- name: Build packages
run: pnpm build-packages

- name: Build e2e
run: pnpm build:e2e
- name: Set npm registry to GitHub Packages
run: |
echo "" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.TOLGEE_MACHINE_PAT }}" >> .npmrc
echo "@tolgee:registry=https://npm.pkg.github.com" >> .npmrc
- name: Publish to GitHub Packages
run: pnpm publish -r --no-git-checks --tag test
env:
NODE_AUTH_TOKEN: ${{secrets.TOLGEE_MACHINE_PAT}}

- id: set-dirs
run: echo "dirs=$(ls | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
Expand All @@ -102,27 +82,27 @@ jobs:
dirs: ${{ steps.set-dirs.outputs.dirs }}

cypress:
name: 'Cypress'
# cypress-prepare will install and build everything into cache
needs: cypress-prepare
name: E2e
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
app: ${{ fromJson(needs.cypress-prepare.outputs.dirs) }}
app: ${{ fromJson(needs.prepare.outputs.dirs) }}
node: [16, 18]

steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: ${{ matrix.node }}

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- uses: actions/cache@v3
Expand All @@ -135,20 +115,36 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-cypress-
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-cypress-${{ github.sha }}
restore-keys: |
turbo-cypress-
- name: Install for root and for e2e
run: |
pnpm install --ignore-workspace
pnpm install --no-frozen-lockfile --filter='./e2e'
- name: Install
run: pnpm install --no-frozen-lockfile
- name: Create branch
run: git checkout -b test.$(git ls-files -s packages | git hash-object --stdin)

- name: Cypress
run: pnpm run e2e run --headed ${{matrix.app}} --stdout prod,dev
- name: Update version with lerna
run: |
lerna version prerelease --yes --conventional-prerelease --preid test.$(git ls-files -s packages | git hash-object --stdin) --ignore-scripts \
--force-publish --no-push --no-git-tag-version --exact
- name: Remove 'workspace' field from package.json
run: node scripts/packageJsonRemoveWorkspaces.js

- name: Install testapp dependencies with npm
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.TOLGEE_MACHINE_PAT }}" >> .npmrc
echo "@tolgee:registry=https://npm.pkg.github.com" >> .npmrc
rm -rf node_modules
npm install --force
working-directory: testapps/${{matrix.app}}

- name: Build testapp
run: npm run build
working-directory: testapps/${{matrix.app}}

- name: Run e2e tests
run: pnpm run e2e run --headed ${{matrix.app}} --stdout prod,dev --skip-build

- uses: actions/upload-artifact@v2
if: failure()
Expand All @@ -158,8 +154,8 @@ jobs:
e2e/cypress/videos/**/*
e2e/cypress/screenshots/**/*
code-checks:
name: Eslint 🪲
static-checks:
name: Static check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -172,21 +168,22 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.16.0
version: 8.6.12
run_install: false

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: .pnpm-store/v3
key: ${{ runner.os }}-pnpm-eslint-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-pnpm-lint-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-eslint-
${{ runner.os }}-pnpm-lint-
- name: Install
run: pnpm install --no-frozen-lockfile
working-directory: ./

- name: Eslint
run: pnpm run eslint
working-directory: ./

- name: Eslint
run: pnpm --prefix e2e run eslint
45 changes: 45 additions & 0 deletions e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"env": {
"es2021": true
},
"ignorePatterns": [
"**/*.generated.*",
"*.js"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"prettier",
"no-only-tests"
],
"rules": {
"prettier/prettier": "error",
"no-console": "warn",
"no-only-tests/no-only-tests": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "none",
"varsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-interface": "off"
}
}
2 changes: 1 addition & 1 deletion e2e/cypress/common/namespacesTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const namespacesTest = (
items: Record<string, { text: string; count: number; testId?: string }[]>,
options?: { skipLoading: boolean }
) =>
describe.only('translation methods test', () => {
describe('translation methods test', () => {
before(() => {
cy.visit(url + '/translation-methods');
cy.intercept('GET', '*', (req) => {
Expand Down
Loading

0 comments on commit 2de9bac

Please sign in to comment.