Skip to content

Commit

Permalink
ci: frontend code auto lint (#3)
Browse files Browse the repository at this point in the history
* Create lint-js.yml

* Update lint-js.yml

* Update lint-js.yml

* Update lint-js.yml

* Update lint-js workflow
  • Loading branch information
Broken-Deer authored Aug 15, 2024
1 parent f49c243 commit 67173e6
Show file tree
Hide file tree
Showing 74 changed files with 3,965 additions and 8,692 deletions.
26 changes: 11 additions & 15 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
require("@rushstack/eslint-patch/modern-module-resolution")

module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript'
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
'vue/multi-word-component-names': 'off',
'vue/valid-template-root': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
root: true,
extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/eslint-config-typescript"],
parserOptions: {
ecmaVersion: "latest",
},
rules: {
"vue/multi-word-component-names": "off",
"vue/valid-template-root": "off",
"@typescript-eslint/no-unused-vars": "off",
},
}
163 changes: 82 additions & 81 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,88 +16,89 @@ jobs:
echo "text=$(jq -r .version src-tauri/tauri.conf.json)" >> "$GITHUB_OUTPUT"
outputs:
app_version: ${{ steps.step.outputs.text }}
# TODO: wait for github support aarch64
# build-arm-linux:
# needs: [get-version]
# runs-on: ubuntu-22.04
# strategy:
# fail-fast: false
# matrix:
# arch: [aarch64, armv7l]
# include:
# - arch: aarch64
# cpu: cortex-a72
# base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bookworm.img.xz
# deb: arm64
# rpm: aarch64
# appimage: aarch64
# - arch: armv7l
# cpu: cortex-a53
# deb: armhfp
# rpm: arm
# appimage: armhf
# base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz

# steps:
# - uses: actions/checkout@v4

# - name: Cache rust build artifacts
# uses: Swatinem/rust-cache@v2
# with:
# workspaces: src-tauri
# cache-on-failure: true

# - name: Build app
# uses: pguyot/arm-runner-action@v2.6.5
# with:
# base_image: ${{ matrix.base_image }}
# cpu: ${{ matrix.cpu }}
# bind_mount_repository: true
# image_additional_mb: 10240
# optimize_image: no
# exit_on_fail: no
# commands: |
# # Prevent Rust from complaining about $HOME not matching eid home
# export HOME=/root

# # Workaround to CI worker being stuck on Updating crates.io index
# export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse

# # Install setup prerequisites
# apt-get update -y --allow-releaseinfo-change
# apt-get autoremove -y
# apt-get install -y --no-install-recommends --no-install-suggests curl libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 wget file
# curl https://sh.rustup.rs -sSf | sh -s -- -y
# . "$HOME/.cargo/env"
# curl -fsSL https://deb.nodesource.com/setup_lts.x | bash
# apt-get install -y nodejs

# # Install yarn
# npm install -g yarn

# # Install frontend dependencies
# yarn install

# # Build the application
# yarn tauri build -- --verbose

# - name: Upload deb bundle
# uses: actions/upload-artifact@v4
# with:
# name: Debian Bundle
# path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/amethyst-launcher_${{ needs.get-version.outputs.app_version }}_${{ matrix.deb }}.deb

# - name: Upload rpm bundle
# uses: actions/upload-artifact@v4
# with:
# name: RPM Bundle
# path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/amethyst-launcher-${{ needs.get-version.outputs.app_version }}-1.${{ matrix.rpm }}.rpm

# - name: Upload appimage bundle
# uses: actions/upload-artifact@v4
# with:
# name: AppImage Bundle
# path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/amethyst-launcher_${{ needs.get-version.outputs.app_version }}_${{ matrix.appimage }}.AppImage

build-arm-linux:
needs: [get-version]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch: [aarch64, armv7l]
include:
- arch: aarch64
cpu: cortex-a72
base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bookworm.img.xz
deb: arm64
rpm: aarch64
appimage: aarch64
- arch: armv7l
cpu: cortex-a53
deb: armhfp
rpm: arm
appimage: armhf
base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz

steps:
- uses: actions/checkout@v4

- name: Cache rust build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
cache-on-failure: true

- name: Build app
uses: pguyot/arm-runner-action@v2.6.5
with:
base_image: ${{ matrix.base_image }}
cpu: ${{ matrix.cpu }}
bind_mount_repository: true
image_additional_mb: 10240
optimize_image: no
exit_on_fail: no
commands: |
# Prevent Rust from complaining about $HOME not matching eid home
export HOME=/root
# Workaround to CI worker being stuck on Updating crates.io index
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
# Install setup prerequisites
apt-get update -y --allow-releaseinfo-change
apt-get autoremove -y
apt-get install -y --no-install-recommends --no-install-suggests curl libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 wget file
curl https://sh.rustup.rs -sSf | sh -s -- -y
. "$HOME/.cargo/env"
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash
apt-get install -y nodejs
# Install yarn
npm install -g yarn
# Install frontend dependencies
yarn install
# Build the application
yarn tauri build -- --verbose
- name: Upload deb bundle
uses: actions/upload-artifact@v4
with:
name: Debian Bundle
path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/amethyst-launcher_${{ needs.get-version.outputs.app_version }}_${{ matrix.deb }}.deb

- name: Upload rpm bundle
uses: actions/upload-artifact@v4
with:
name: RPM Bundle
path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/amethyst-launcher-${{ needs.get-version.outputs.app_version }}-1.${{ matrix.rpm }}.rpm

- name: Upload appimage bundle
uses: actions/upload-artifact@v4
with:
name: AppImage Bundle
path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/amethyst-launcher_${{ needs.get-version.outputs.app_version }}_${{ matrix.appimage }}.AppImage
build-other:
needs: [get-version]
permissions:
Expand Down
74 changes: 37 additions & 37 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]
schedule:
- cron: '19 4 * * 1'
- cron: "19 4 * * 1"

jobs:
analyze:
Expand All @@ -44,8 +44,8 @@ jobs:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none
- language: javascript-typescript
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
Expand All @@ -55,39 +55,39 @@ jobs:
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
34 changes: 34 additions & 0 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: lint js

on:
push:
paths:
- ".github/workflows/lint-js.yml"
- "src/*"

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

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20"
cache: yarn
cache-dependency-path: yarn.lock
- name: Run ts:check
working-directory: ./
run: yarn ts:check
- name: Install Dependencies
working-directory: ./
run: yarn
- name: Run lint
working-directory: ./
run: yarn lint
- name: Run format
working-directory: ./
run: yarn format:check
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src-tauri/target
**/assets
**/.gitignore
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"semi": false,
"tabWidth": 4,
"printWidth": 100,
"useTabs": false,
"singleQuote": false,
"bracketSameLine": true,
"overrides": [
{
"files": ["*.vue", "*.html", "*.yml"],
"options": {
"tabWidth": 2
}
}
]
}
Loading

0 comments on commit 67173e6

Please sign in to comment.