Skip to content

Commit

Permalink
Testing the CI/CD process on the master branch on my fork (#582)
Browse files Browse the repository at this point in the history
- [x] Changed the `package.json` `repository` to `baruchiro`. Need to
revert before merge.
- [x] Need to check with Google Credentials because they are not
configured in my repo.
- [ ] When using the default config, on Mac, the file exporters get
"readonly filesystem". The problem is they are not failed but running
forever. **I can live with that**
- [ ] run prettier --write on the target branch **some day, in dedicated
commit and PR**

- I removed the `CHANGELOG` file and the updated version from the
`package.json` as suggested
[here](https://semantic-release.gitbook.io/semantic-release/support/faq#making-commits-during-the-release-process-adds-significant-complexity)
- We can continue with the failing pipelines, and not mark them as
required. I commented out the OS matrix for tests to run only on Linux
to save machine time.

#### Tested Platforms

Test this version:
https://github.com/baruchiro/caspion/releases/tag/v1.33.4

- [x] Mac (Apple Silicon): Tested by @baruchiro 
  - [x] CSV: @baruchiro 
  - [x] Excel: @baruchiro 
  - [ ] YNAB
  - [x] Google Sheets: @baruchiro 
- [ ] Mac (Intel Silicon)
  - [ ] CSV
  - [ ] Excel 
  - [ ] YNAB
  - [ ] Google Sheets 
- [ ] Windows
  - [ ] CSV 
  - [ ] Excel 
  - [ ] YNAB
  - [ ] Google Sheets 
- [ ] Linux
  - [ ] CSV 
  - [ ] Excel 
  - [ ] YNAB
  - [ ] Google Sheets
  • Loading branch information
baruchiro authored Sep 17, 2024
1 parent 1a05f81 commit 366ab6d
Show file tree
Hide file tree
Showing 23 changed files with 417 additions and 167 deletions.
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_APP_VERSION=$npm_package_version
VITE_APP_NAME=$npm_package_name
VITE_APP_VERSION=0.0.0
VITE_APP_NAME=caspion

SENTRY_DSN=
VITE_SENTRY_DSN=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_ID=
VITE_GOOGLE_CLIENT_ID=
VITE_GOOGLE_CLIENT_SECRET=
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on:
workflow_dispatch:
pull_request:

jobs:
build:
strategy:
fail-fast: true
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'yarn'
- name: Install dependencies
run: yarn
- name: Build
run: yarn compile


49 changes: 0 additions & 49 deletions .github/workflows/ci.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Lint

on:
workflow_dispatch:
push:
Expand Down Expand Up @@ -40,6 +42,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- run: yarn
env:
Expand All @@ -56,6 +59,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- run: yarn add prettier
- run: npx prettier --check "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx,vue}"
- run: yarn format:check
40 changes: 40 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PR Title

on:
pull_request:
types: [opened, edited, synchronize, reopened]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: deepakputhraya/action-pr-title@3864bebc79c5f829d25dd42d3c6579d040b0ef16
name: Validate PR Title
continue-on-error: false
with:
regex: '\w+:( [\w\.,]+)+( \(\w+ #\d+\))?' # Regex the title should match. "Level: message (optional #123)"
allowed_prefixes: 'Breaking,Build,Chore,Fix,New,Update,Upgrade,Deps' # title should start with the given prefix
# disallowed_prefixes: 'feat/,hotfix' # title should not start with the given prefix
prefix_case_sensitive: true # title prefix are case insensitive
# min_length: 5 # Min length of the title
max_length: 50 # Max length of the title
github_token: ${{ secrets.GITHUB_TOKEN }} # Default: ${{ github.token }}
- uses: mshick/add-pr-comment@07f690343c25a94e24a8acb70d03c86b701ae322
name: Comment on PR
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
Please fix the title of this PR.
Examples:
```
Breaking: I broke something
Fix: fix (fixes #1234)
Update: some packages updates (refs #123)
New: Added a new feature
```
See more in `release.config.js`.
87 changes: 69 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Release
on:
push:
branches:
- vite-electron-builder
workflow_call:
workflow_dispatch:
inputs:
dry-run:
description: 'Compiles the app but not upload artifacts to distribution server'
# TODO: default: false
default: true
version:
description: 'Exsiting version to publish files. If not provided, will create a new release.'
required: false
type: boolean
type: string

push:
branches:
- master
paths-ignore:
- 'nuxt/**'

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false


defaults:
Expand All @@ -23,7 +24,45 @@ defaults:


jobs:
draft_release:
release:
runs-on: ubuntu-latest

outputs:
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_published: ${{ steps.semantic.outputs.new_release_published }}

steps:
- uses: actions/checkout@v4
# https://github.com/nodejs/node-gyp/issues/2869
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'yarn'

- name: Install semantic-release dependencies
run: yarn add -D @semantic-release/commit-analyzer conventional-changelog-eslint
- uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4
id: semantic
if: inputs.version == ''
with:
semantic_version: 24.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: [release]
if: needs.release.outputs.new_release_published == 'true' || inputs.version != ''
env:
NEW_RELEASE_PUBLISHED: ${{ inputs.version && 'true' || needs.release.outputs.new_release_published }}
NEW_RELEASE_VERSION: ${{ needs.release.outputs.new_release_version || inputs.version }}

NODE_ENV: production
MODE: production
VITE_GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
VITE_GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}

permissions:
contents: write # Allows this job to create releases
Expand All @@ -33,8 +72,8 @@ jobs:
matrix:
os:
- macos-latest
# - ubuntu-latest
# - windows-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

Expand All @@ -44,14 +83,27 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@d33c176a9b784876d966f80fb1b461808edc0641
# Only install Snapcraft on Ubuntu
if: startsWith(matrix.os, 'ubuntu')
continue-on-error: true
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}

- name: set version
run: yarn version --no-git-tag-version --new-version ${{ env.NEW_RELEASE_VERSION }}

- run: yarn
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
NODE_ENV: development

- run: yarn build

- name: Compile artifacts ${{ inputs.dry-run && '' || 'and upload them to github release' }}
- name: Compile artifacts ${{ env.NEW_RELEASE_PUBLISHED == 'true' && 'and upload them to github release' || '' }}
# I use this action because it is capable of retrying multiple times if there are any issues with the distribution server
uses: nick-fields/retry@v3
with:
Expand All @@ -62,13 +114,12 @@ jobs:
shell: 'bash'
# Due to this issue https://github.com/electron-userland/electron-builder/issues/6411 the build with npx when rebuilding native dependencies hangs forever
# see https://github.com/cawa-93/vite-electron-builder/pull/953
command: ./node_modules/.bin/electron-builder --config electron-builder.yml --publish ${{ inputs.dry-run && 'never' || 'always' }}
command: ./node_modules/.bin/electron-builder --config electron-builder.yml --publish $PUBLISH_PARAM
env:
# Code Signing params
# See https://www.electron.build/code-signing
# CSC_LINK: ''
# CSC_KEY_PASSWORD: ''
# Publishing artifacts
GH_TOKEN: ${{ secrets.github_token }} # GitHub token, automatically provided (No need to define this secret in the repo settings)
NODE_ENV: production
MODE: production
GH_TOKEN: ${{ secrets.github_token }}
PUBLISH_PARAM: ${{ env.NEW_RELEASE_PUBLISHED == 'true' && 'always' || 'never' }}
11 changes: 9 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Tests
on: [ workflow_call ]
on:
workflow_dispatch:
pull_request:

concurrency:
group: tests-${{ github.ref }}
Expand All @@ -14,13 +16,18 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
os:
# - windows-latest
- ubuntu-latest
# - macos-latest

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'
- run: yarn
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/typechecking.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Typechecking
on: [ workflow_call ]
on:
workflow_dispatch:
pull_request:

concurrency:
group: typechecking-${{ github.ref }}
Expand All @@ -18,6 +20,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.node-version'

- run: yarn
env:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"request": "launch",
"name": "Debug Main Process",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\\scripts\\watch.js",
"program": "${workspaceFolder}/scripts/watch.js",
"autoAttachChildProcesses": true
}
]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ If you wish though to build/debug this from source, you will need to setup your
Now that you have the keys above, store them as env variables:

```
EXPORT GOOGLE_CLIENT_ID=XXXXX
EXPORT GOOGLE_CLIENT_SECRET=YYYYYY
EXPORT VITE_GOOGLE_CLIENT_ID=XXXXX
EXPORT VITE_GOOGLE_CLIENT_SECRET=YYYYYY
```

That's it. Next time you'll run the code a one time OAuth authorization window will appear and ask for access.
Expand Down
4 changes: 4 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ files:

linux:
target: deb

publish:
- provider: github
releaseType: release
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"typecheck:renderer": "tsc --noEmit -p packages/renderer/tsconfig.json",
"typecheck": "yarn typecheck:main && yarn typecheck:preload && yarn typecheck:renderer",
"postinstall": "cross-env ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.js",
"format": "prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\""
"format": "prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\"",
"format:check": "prettier --check \"**/*.{js,mjs,cjs,ts,mts,cts,tsx,json}\""
},
"devDependencies": {
"@semantic-release/commit-analyzer": "^13.0.0",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.4.8",
Expand Down Expand Up @@ -69,7 +71,7 @@
"bottleneck": "^2.19.5",
"csv-parse": "^5.5.6",
"csv-stringify": "^6.5.0",
"electron-google-oauth2": "^3.0.0",
"electron-google-oauth2": "^3.1.0",
"electron-log": "^5.1.5",
"electron-updater": "6.2.1",
"emittery": "^1.0.3",
Expand Down
Loading

0 comments on commit 366ab6d

Please sign in to comment.