From e790d93a75582a2ff8304d75ef2cad52bdb8ea7c Mon Sep 17 00:00:00 2001 From: Afonso Jorge Ramos Date: Mon, 11 Dec 2023 01:59:39 +0000 Subject: [PATCH 1/3] chore: cleanup workflows --- .github/workflows/build-app.yml | 123 ++++++-------------------------- .github/workflows/release.yml | 117 ++++++------------------------ .github/workflows/run-tests.yml | 45 +++--------- .github/workflows/validator.yml | 6 -- package.json | 4 +- pnpm-lock.yaml | 16 +++++ 6 files changed, 69 insertions(+), 242 deletions(-) diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index 61fa14856..004a6c73b 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -11,147 +11,66 @@ on: jobs: build-macos: + name: Build macOS (electron-builder) runs-on: macos-latest steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install + - uses: actions/setup-node@v4 with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build - run: pnpm build - - - name: Make macOS (electron-builder) + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm build + - run: pnpm make:macos --publish=never -c.mac.identity=null env: CSC_LINK: ${{ secrets.mac_certs }} CSC_KEY_PASSWORD: ${{ secrets.mac_certs_password }} - run: pnpm make:macos --publish=never -c.mac.identity=null - - name: Clean up builds run: rm -rfv dist/mac-universal - - uses: actions/upload-artifact@v3 with: name: Gitify-dist-mac path: dist/ build-windows: + name: Build Windows (electron-builder) runs-on: windows-latest steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - uses: actions/setup-node@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build - run: pnpm build - - - name: Make Windows (electron-builder) - run: pnpm make:win --publish=never - + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm build + - run: pnpm make:win --publish=never - name: Clean up builds run: Remove-Item dist/win-unpacked -Recurse - - uses: actions/upload-artifact@v3 with: name: Gitify-dist-win path: dist build-linux: + name: Build Linux (electron-builder) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install + - uses: actions/setup-node@v4 with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build - run: pnpm build - - - name: Make Linux (electron-builder) - run: pnpm make:linux --publish=never - + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm build + - run: pnpm make:linux --publish=never - name: Clean up builds run: rm -rfv dist/linux-unpacked - - uses: actions/upload-artifact@v3 with: name: Gitify-dist-linux diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9357e796..e1ae726f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,46 +7,22 @@ on: jobs: release-macos: + name: Publish macOS (electron-builder) runs-on: macos-latest steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install + - uses: actions/setup-node@v4 with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm build env: OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }} OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }} - run: pnpm build - - - name: Publish macOS (electron-builder) + - run: pnpm make:macos --publish onTagOrDraft env: APPLEID_USERNAME: ${{ secrets.appleid_username }} APPLEID_PASSWORD: ${{ secrets.appleid_password }} @@ -54,94 +30,43 @@ jobs: CSC_KEY_PASSWORD: ${{ secrets.mac_certs_password }} GH_TOKEN: ${{ secrets.gh_token }} NOTARIZE: true - run: pnpm make:macos --publish onTagOrDraft release-windows: + name: Publish Windows (electron-builder) runs-on: windows-latest steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install + - uses: actions/setup-node@v4 with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm build env: OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }} OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }} - run: pnpm build - - - name: Publish Windows (electron-builder) + - run: pnpm make:win --publish onTagOrDraft env: GH_TOKEN: ${{ secrets.gh_token }} - run: pnpm make:win --publish onTagOrDraft release-linux: + name: Publish Linux (electron-builder) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install + - uses: actions/setup-node@v4 with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Build + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm build env: OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }} OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }} - run: pnpm build - - - name: Publish Linuxs (electron-builder) + - run: pnpm make:linux --publish onTagOrDraft env: GH_TOKEN: ${{ secrets.gh_token }} - run: pnpm make:linux --publish onTagOrDraft diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 909d37d1c..352ddb4bb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,6 +1,6 @@ name: Run Tests -on: +on: push: branches: - main @@ -12,43 +12,14 @@ jobs: steps: - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache + - uses: actions/setup-node@v4 with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Run Prettier (Check) - run: pnpm prettier:check - - - name: Run Typechecking - run: pnpm tsc --noEmit - - - name: Run Jest - run: pnpm test -- --coverage --runInBand --verbose - + node-version-file: '.nvmrc' + cache: 'pnpm' + - run: pnpm install + - run: pnpm prettier:check + - run: pnpm tsc --noEmit + - run: pnpm test -- --coverage --runInBand --verbose - name: Coveralls uses: coverallsapp/github-action@v2 diff --git a/.github/workflows/validator.yml b/.github/workflows/validator.yml index ba383e24e..ead305b6c 100644 --- a/.github/workflows/validator.yml +++ b/.github/workflows/validator.yml @@ -35,18 +35,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 with: node-version-file: .nvmrc - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install with: run_install: false - - run: pnpm install --global renovate - - name: Validate Renovate config run: renovate-config-validator diff --git a/package.json b/package.json index 54b02f6f6..e6fc8ed3b 100644 --- a/package.json +++ b/package.json @@ -116,8 +116,10 @@ "@testing-library/react": "14.0.0", "@types/jest": "29.5.10", "@types/node": "18.18.0", + "@types/nprogress": "^0.2.3", "@types/react": "18.2.42", "@types/react-router-dom": "5.3.3", + "@types/react-test-renderer": "^18.0.7", "@types/react-transition-group": "4.4.7", "autoprefixer": "10.4.16", "css-loader": "6.8.1", @@ -138,7 +140,7 @@ "webpack-cli": "5.1.4", "webpack-merge": "5.9.0" }, - "packageManager": "pnpm@8.9.0", + "packageManager": "pnpm@8.11.0", "lint-staged": { "*.{md,js,ts,tsx}": "prettier --write" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5324435fc..f62f09412 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,12 +67,18 @@ devDependencies: '@types/node': specifier: 18.18.0 version: 18.18.0 + '@types/nprogress': + specifier: ^0.2.3 + version: 0.2.3 '@types/react': specifier: 18.2.42 version: 18.2.42 '@types/react-router-dom': specifier: 5.3.3 version: 5.3.3 + '@types/react-test-renderer': + specifier: ^18.0.7 + version: 18.0.7 '@types/react-transition-group': specifier: 4.4.7 version: 4.4.7 @@ -1083,6 +1089,10 @@ packages: /@types/node@18.18.0: resolution: {integrity: sha512-3xA4X31gHT1F1l38ATDIL9GpRLdwVhnEFC8Uikv5ZLlXATwrCYyPq7ZWHxzxc3J/30SUiwiYT+bQe0/XvKlWbw==} + /@types/nprogress@0.2.3: + resolution: {integrity: sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA==} + dev: true + /@types/plist@3.0.2: resolution: {integrity: sha512-ULqvZNGMv0zRFvqn8/4LSPtnmN4MfhlPNtJCTpKuIIxGVGZ2rYWzFXrvEBoh9CVyqSE7D6YFRJ1hydLHI6kbWw==} requiresBuild: true @@ -1117,6 +1127,12 @@ packages: '@types/react': 18.2.42 dev: true + /@types/react-test-renderer@18.0.7: + resolution: {integrity: sha512-1+ANPOWc6rB3IkSnElhjv6VLlKg2dSv/OWClUyZimbLsQyBn8Js9Vtdsi3UICJ2rIQ3k2la06dkB+C92QfhKmg==} + dependencies: + '@types/react': 18.2.42 + dev: true + /@types/react-transition-group@4.4.7: resolution: {integrity: sha512-ICCyBl5mvyqYp8Qeq9B5G/fyBSRC0zx3XM3sCC6KkcMsNeAHqXBKkmat4GqdJET5jtYUpZXrxI5flve5qhi2Eg==} dependencies: From 9d52180a2075b27aaa40b3548870970d6d686919 Mon Sep 17 00:00:00 2001 From: Afonso Jorge Ramos Date: Mon, 11 Dec 2023 02:23:06 +0000 Subject: [PATCH 2/3] fix: types --- src/components/Loading.test.tsx | 21 +-- src/routes/Settings.test.tsx | 9 +- src/routes/Settings.tsx | 5 +- .../__snapshots__/Settings.test.tsx.snap | 177 ++++++++---------- 4 files changed, 91 insertions(+), 121 deletions(-) diff --git a/src/components/Loading.test.tsx b/src/components/Loading.test.tsx index 603b2f713..21b06474b 100644 --- a/src/components/Loading.test.tsx +++ b/src/components/Loading.test.tsx @@ -1,25 +1,20 @@ -import React from 'react'; import { render } from '@testing-library/react'; import NProgress from 'nprogress'; +import React from 'react'; import { AppContext } from '../context/App'; import { Loading } from './Loading'; -jest.mock('nprogress', () => { - return { - configure: jest.fn(), - start: jest.fn(), - done: jest.fn(), - remove: jest.fn(), - }; -}); +jest.mock('nprogress', () => ({ + configure: jest.fn(), + start: jest.fn(), + done: jest.fn(), + remove: jest.fn(), +})); describe('components/Loading.js', () => { beforeEach(() => { - NProgress.configure.mockReset(); - NProgress.start.mockReset(); - NProgress.done.mockReset(); - NProgress.remove.mockReset(); + jest.clearAllMocks(); }); it('should check that NProgress is getting called in when isFetching changes (loading)', () => { diff --git a/src/routes/Settings.test.tsx b/src/routes/Settings.test.tsx index daa7d38e6..46d31292a 100644 --- a/src/routes/Settings.test.tsx +++ b/src/routes/Settings.test.tsx @@ -1,7 +1,6 @@ -import { fireEvent, render, screen } from '@testing-library/react'; +import { act, fireEvent, render, screen } from '@testing-library/react'; import React from 'react'; import { MemoryRouter } from 'react-router-dom'; -import TestRenderer, { act } from 'react-test-renderer'; const { ipcRenderer } = require('electron'); @@ -31,10 +30,8 @@ describe('routes/Settings.tsx', () => { }); it('should render itself & its children', async () => { - let tree: TestRenderer; - await act(async () => { - tree = TestRenderer.create( + render( @@ -44,7 +41,7 @@ describe('routes/Settings.tsx', () => { , ); }); - expect(tree).toMatchSnapshot(); + expect(screen.getByTestId('settings')).toMatchSnapshot(); }); it('should press the logout', async () => { diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index b43551699..1e38762a0 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -77,7 +77,10 @@ export const SettingsRoute: React.FC = () => { 'hover:text-gray-500 py-1 px-2 my-1 mx-2 focus:outline-none'; return ( -
+

Settings

Appearance
@@ -148,151 +136,141 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
@@ -300,10 +278,10 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `
Gitify v 0.0.1 @@ -311,13 +289,12 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = `