Skip to content

Commit

Permalink
ci: fix warnings and PR build (0LNetworkCommunity#232)
Browse files Browse the repository at this point in the history
* CI: Fix warnings, add PR Build check

* ci: mocked keys
  • Loading branch information
kalvkusk authored Feb 20, 2024
1 parent 17715da commit 28cb756
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 17 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: build

on:
workflow_dispatch:
push:
tags:
- '*'
branches:
- '*'
pull_request:
types:
- opened
branches:
- 'release**'
- 'main'

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-latest ]
name: build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
### DO NOT REMOVE: uncomment if you need to debug runner ###
# - name: setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true
# checkout
# Setup Rust
- name: checkout sources
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set rust_version from rust_toolchain file
run: echo "RUST_VERSION=$(cat src-tauri/rust-toolchain)" >> $GITHUB_ENV

- name: Set rust_version from rust_toolchain file
if: matrix.os == 'windows-latest'
run: |
Get-Content -Path src-tauri/rust-toolchain | Tee-Object -variable RUST_VERSION
echo "RUST_VERSION=$RUST_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
- uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: "${{ env.RUST_VERSION }}"
override: true

# Setup Node.js
- name: setup node
uses: actions/[email protected]
with:
node-version: 18

- name: install dependencies (windows only)
if: matrix.os == 'windows-latest'
uses: KyleMayes/install-llvm-action@v1
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm

- name: Set LIBCLANG_PATH
if: matrix.os == 'windows-latest'
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV

# Package the windows dependencies
- name: copy gmp.dll for build
if: matrix.os == 'windows-latest'
run: |
$var = (get-item $(rustup which rustc)).Directory.Parent.FullName+ '\lib\rustlib\' + (rustc -vV | findstr "host:*").split(':')[1].Trim() + '\lib'
Copy-Item ('${{ github.workspace }}' + '\redist' + '\x86_64\*') -Destination $var -Recurse
######## CACHE ########

- uses: Swatinem/rust-cache@v2
with:
workspaces: ./src-tauri
shared-key: "${{ matrix.os }}"
cache-all-crates: true
cache-on-failure: true


######## BUILD ########

- name: yarn installation
run: yarn install

- name: pre-build rust
working-directory: ./src-tauri
run: cargo b --release

- name: build tauri
run: yarn run build:github-pr
env:
# Mocked keys.
TAURI_PRIVATE_KEY: "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5ZUYrUFF0RS9ZbU5EN0VFWk52TmpDRDQvTFFWOHhqSXNkZFVvUjZSRWNJc0FBQkFBQUFBQUFBQUFBQUlBQUFBQTZhNUxkYVFJWDNWTENKR2tSNzFVcDhsRzcvd0lKeWRGcytBZDNyZ3o3OWRXOWVmbmZCQktJYk8xOHVHWG5CZ25XN1pBOXM3SjMyWW1DRFNZWFJ5WGxsd3B6d3RvOEtTNHFFbFM5VE5obmNEZ1dHeEljVFRhZ2FXa0RzNHZOVkNESE5DdDArUmkvUUE9Cg=="
TAURI_KEY_PASSWORD: "mock"
30 changes: 16 additions & 14 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
pull_request:
types:
- opened
- synchronize
branches:
- 'release**'
- 'main'
Expand All @@ -20,12 +19,13 @@ jobs:

# Setup Node.js
- name: setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.2
with:
node-version: 18
node-version: 20

# checkout
- name: checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4.1.1

- name: yarn installation
run: yarn install
Expand All @@ -40,31 +40,33 @@ jobs:
# with:
# packages: build-essential lld pkg-config libclang-dev libwebkit2gtk-4.0-dev libglib2.0-* libssl-dev libgtk-3-dev libappindicator3-dev patchelf librsvg2-dev libvips-dev libgmp-dev
# version: 1.0

- uses: actions-rs/toolchain@v1
- name: checkout sources
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set rust_version from rust_toolchain file
run: echo "RUST_VERSION=$(cat src-tauri/rust-toolchain)" >> $GITHUB_ENV

- uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: 1.70.0
toolchain: ${{ env.RUST_VERSION }}
override: true

- name: install rustfmt clippy
shell: bash
run: rustup component add rustfmt clippy

- name: checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: cache rust
uses: Swatinem/rust-cache@v2
with:
shared-key: "libra" # to share across CI builds, so it is not job-id specific
cache-on-failure: true

- name: check format
working-directory: ./src-tauri
run: cargo fmt --all -- --check
run: cargo fmt --all -- --check

- name: lint
working-directory: ./src-tauri
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: carpe-release
name: release

on:
workflow_dispatch:
Expand Down Expand Up @@ -34,12 +34,12 @@ jobs:

# Setup Node.js
- name: setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.2
with:
node-version: 18
# checkout
- name: checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4.1.1

- name: install dependencies (windows only)
if: matrix.os == 'windows-latest'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:universal": "tauri build --target universal-apple-darwin",
"build:aarch64": "RUSTFLAGS='--cfg tokio_unstable' tauri build --target aarch64-apple-darwin",
"build:canary": "tauri build --config src-tauri/tauri.conf.canary.json --features carpe-canary",
"build:github-pr": "tauri build --config src-tauri/tauri.conf.pr.json --features carpe-pr",
"build:web": "vite build",
"lint": "svelte-check --tsconfig ./tsconfig.json && eslint src && prettier --check src",
"format": "eslint --fix src/* && prettier --write src"
Expand Down
1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ tauri = { version = "^1.5.2", features = ["api-all", "updater"] }
custom-protocol = ["tauri/custom-protocol"]
default = ["custom-protocol"]
carpe-canary = [] # for building canary versions which use separate config dirs.
carpe-pr = [] # for building pr versions which use separate config dirs.

[dev-dependencies]
serde_yaml = "0.8.24"
Expand Down
84 changes: 84 additions & 0 deletions src-tauri/tauri.conf.pr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"package": {
"productName": "carpe-pr",
"version": "1.0.0"
},
"build": {
"distDir": "../dist",
"devPath": "http://localhost:3000",
"beforeDevCommand": "yarn dev:web",
"beforeBuildCommand": "yarn build:web"
},
"tauri": {
"updater": {
"active": true,
"endpoints": [
"https://raw.githubusercontent.com/0LNetworkCommunity/carpe/main/autoupdater/non_existent.json"
],
"dialog": false,
"pubkey":"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI1NEM2REJBMjU1MUQxMjQKUldRazBWRWx1bTFNdFY4bmxyVEg4NVFvZXFlMnNacGF0VlNLYSs1RmNENzFWaUx0amhOSjI0UU0K"
},
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.CarpeCanary",
"icon": [
"icons-canary/32x32.png",
"icons-canary/128x128.png",
"icons-canary/[email protected]",
"icons-canary/icon.icns",
"icons-canary/icon.ico"
],
"resources": [
"gmp.dll",
"gmp.lib",
"libgmp-10.dll",
"libcrypto.dylib",
"libcrypto.3.dylib",
"libssl.dylib",
"libssl.3.dylib"
],
"externalBin": [],
"copyright": "",
"category": "DeveloperTool",
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": []
},
"macOS": {
"frameworks": [],
"minimumSystemVersion": "",
"exceptionDomain": "localhost",
"signingIdentity": null,
"entitlements": null
},
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": "",
"webviewInstallMode": {
"type": "embedBootstrapper"
}
}
},
"allowlist": {
"all": true,
"fs": {
"all": true
}
},
"windows": [
{
"title": "CARPE PR",
"width": 1000,
"height": 800,
"resizable": true,
"fullscreen": false
}
],
"security": {
"csp": "default-src 'self' blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'"
}
}
}

0 comments on commit 28cb756

Please sign in to comment.