Skip to content

Commit

Permalink
Update github actions due to nodejs 16 deprecation (#2107)
Browse files Browse the repository at this point in the history
* Update github actions due to nodejs 16 deprecation
 - Replace archived actions-rs/clippy-check with maintained fork actions-rs-plus/clippy-check
 - Replace redhat-actions/push-to-registry with updated fork Eusebiotrigo/push-to-registry
 - Point redhat-actions/buildah-build and softprops/action-gh-release to current master to fix nodejs deprecation

* Build the correct ios core rust arch for CI runs

* Build ios app for the same arch as the host in Mobile CI

* Some changes to try and make cache-factory faster and avoid failing so much

* Add trigger to run cache-factory on pull requests when there are changes to itself

* Attempt to fix sed usage on macOS

* Don't treat warning as errors

* Fix windows

* Fix windows 2

* Use target ad cache key for rust to differentiate between macOS x86_64 and arm64

* Use faster/better linkers to compile for macOS, Linux and Windows

* Fix missing shell in action

* Fix typo

* Fix missing shell in action 2

* Fix mold download
 - Replace bsdtar with plain tar

* Fix permission denied when extracting mold

* Remove zld

* Don't restore cache for rustfmt
 - Remove target symlink to C:/ in an attempt to speed-up windows CI

* Fix typo

* Restore target symlink on windows
 - Removing it didn't make CI faster

* Run Mobile on macos-14
  • Loading branch information
HeavenVolkoff authored Feb 21, 2024
1 parent 519b1b6 commit 393a907
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 62 deletions.
29 changes: 25 additions & 4 deletions .cargo/config.toml.mustache
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{#nativeDeps}}
[env]
PROTOC = { force = true, value = "{{{protoc}}}" }
FFMPEG_DIR = { force = true, value = "{{{nativeDeps}}}" }
Expand All @@ -7,17 +8,18 @@ ORT_LIB_LOCATION = { force = true, value = "{{{nativeDeps}}}/lib" }
OPENSSL_STATIC = { force = true, value = "1" }
OPENSSL_NO_VENDOR = { force = true, value = "0" }
OPENSSL_RUST_USE_NASM = { force = true, value = "1" }
{{/nativeDeps}}

{{#isMacOS}}
[target.x86_64-apple-darwin]
rustflags = ["-L", "{{{nativeDeps}}}/lib"]
rustflags = ["-L", "{{{nativeDeps}}}/lib", "-Csplit-debuginfo=unpacked"]

[target.x86_64-apple-darwin.heif]
rustc-link-search = ["{{{nativeDeps}}}/lib"]
rustc-link-lib = ["heif"]

[target.aarch64-apple-darwin]
rustflags = ["-L", "{{{nativeDeps}}}/lib"]
rustflags = ["-L", "{{{nativeDeps}}}/lib", "-Csplit-debuginfo=unpacked"]

[target.aarch64-apple-darwin.heif]
rustc-link-search = ["{{{nativeDeps}}}/lib"]
Expand All @@ -26,6 +28,9 @@ rustc-link-lib = ["heif"]

{{#isWin}}
[target.x86_64-pc-windows-msvc]
{{#hasLLD}}
linker = "lld-link.exe"
{{/hasLLD}}
rustflags = ["-L", "{{{nativeDeps}}}\\lib"]

[target.x86_64-pc-windows-msvc.heif]
Expand All @@ -35,14 +40,30 @@ rustc-link-lib = ["heif"]

{{#isLinux}}
[target.x86_64-unknown-linux-gnu]
rustflags = ["-L", "{{{nativeDeps}}}/lib", "-C", "link-arg=-Wl,-rpath=${ORIGIN}/../lib/spacedrive"]
{{#hasLLD}}
linker = "clang"
{{/hasLLD}}
rustflags = [
"-L", "{{{nativeDeps}}}/lib", "-C", "link-arg=-Wl,-rpath=${ORIGIN}/../lib/spacedrive",
{{#hasLLD}}
"-C", "link-arg=-fuse-ld={{{linker}}}",
{{/hasLLD}}
]

[target.x86_64-unknown-linux-gnu.heif]
rustc-link-search = ["{{{nativeDeps}}}/lib"]
rustc-link-lib = ["heif"]

[target.aarch64-unknown-linux-gnu]
rustflags = ["-L", "{{{nativeDeps}}}/lib", "-C", "link-arg=-Wl,-rpath=${ORIGIN}/../lib/spacedrive"]
{{#hasLLD}}
linker = "clang"
{{/hasLLD}}
rustflags = [
"-L", "{{{nativeDeps}}}/lib", "-C", "link-arg=-Wl,-rpath=${ORIGIN}/../lib/spacedrive",
{{#hasLLD}}
"-C", "link-arg=-fuse-ld={{{linker}}}",
{{/hasLLD}}
]

[target.aarch64-unknown-linux-gnu.heif]
rustc-link-search = ["{{{nativeDeps}}}/lib"]
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ runs:
using: 'composite'
steps:
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3
with:
version: 8.x.x

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
token: ${{ inputs.token }}
check-latest: true
Expand Down
33 changes: 30 additions & 3 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
description: Whether to save the Rust cache
required: false
default: 'false'
restore-cache:
description: Whether to restore the Rust cache
required: false
default: 'true'
runs:
using: 'composite'
steps:
Expand All @@ -20,18 +24,41 @@ runs:
components: clippy, rustfmt

- name: Cache Rust Dependencies
if: ${{ inputs.restore-cache == 'true' }}
uses: Swatinem/rust-cache@v2
with:
key: ${{ inputs.target }}
save-if: ${{ inputs.save-cache }}
shared-key: stable-cache

- name: Cargo config.toml
shell: bash
run: echo '{}' | npx -y mustache - .cargo/config.toml.mustache .cargo/config.toml

- name: Turn Off Debuginfo and bump opt-level
shell: bash
if: ${{ runner.os != 'Windows' }}
run: |
sed '/\[profile.dev]/a\
debug = 0
' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
sed '/\[profile.dev]/a\
opt-level=1
' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
- name: Turn Off Debuginfo and bump opt-level
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
(Get-Content Cargo.toml) -replace '\[profile.dev\]', '[profile.dev]
debug = 0' | Set-Content Cargo.toml
(Get-Content Cargo.toml) -replace '\[profile.dev\]', '[profile.dev]
opt-level=1' | Set-Content Cargo.toml
- name: Restore cached Prisma codegen
id: cache-prisma-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
key: prisma-1-${{ runner.os }}-${{ hashFiles('./core/prisma/*', './crates/sync-generator/*', './Cargo.*') }}
path: crates/prisma/src/**/*.rs
Expand All @@ -44,8 +71,8 @@ runs:

- name: Save Prisma codegen
id: cache-prisma-save
if: ${{ inputs.save-cache == 'true' }}
uses: actions/cache/save@v3
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-prisma-restore.outputs.cache-primary-key }}
path: crates/prisma/src/**/*.rs
11 changes: 9 additions & 2 deletions .github/actions/setup-system/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
- name: Restore cached LLVM and Clang
if: ${{ runner.os == 'Windows' }}
id: cache-llvm-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
key: llvm-15
path: C:/Program Files/LLVM
Expand All @@ -37,7 +37,7 @@ runs:
- name: Save LLVM and Clang
if: ${{ runner.os == 'Windows' && inputs.save-cache == 'true' }}
id: cache-llvm-save
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-llvm-restore.outputs.cache-primary-key }}
path: C:/Program Files/LLVM
Expand All @@ -46,6 +46,13 @@ runs:
if: ${{ runner.os != 'Linux' }}
uses: ilammy/setup-nasm@v1

- name: Install Mold
shell: bash
if: ${{ runner.os == 'Linux' }}
run: |
curl -L# 'https://github.com/rui314/mold/releases/download/v2.4.0/mold-2.4.0-x86_64-linux.tar.gz' \
| sudo tar -xzf- -C /usr/local
- name: Setup Rust and Dependencies
uses: ./.github/actions/setup-rust
with:
Expand Down
32 changes: 25 additions & 7 deletions .github/workflows/cache-factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ on:
- main
schedule:
- cron: '0 0 * * *'
pull_request:
paths:
- '.github/workflows/cache-factory.yaml'
workflow_dispatch:

# Cancel previous runs of the same workflow on the same branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# From: https://github.com/rust-lang/rust-analyzer/blob/master/.github/workflows/ci.yaml
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10

jobs:
make_cache:
strategy:
Expand Down Expand Up @@ -53,28 +64,35 @@ jobs:
remove-haskell: 'true'
remove-docker-images: 'true'

- name: Checkout repository
uses: actions/checkout@v3

- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path C:\spacedrive_target
New-Item -Path target -ItemType Junction -Value C:\spacedrive_target
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup System and Rust
uses: ./.github/actions/setup-system
with:
token: ${{ secrets.GITHUB_TOKEN }}
target: ${{ matrix.settings.target }}
save-cache: 'true'

- name: Clippy
run: cargo clippy --workspace --all-features --target ${{ matrix.settings.target }}
- name: Compile tests (debug)
run: cargo test --workspace --all-features --no-run --locked --target ${{ matrix.settings.target }}

- name: Compile tests (release)
run: cargo test --workspace --all-features --no-run --locked --release --target ${{ matrix.settings.target }}

# It's faster to `test` before `build` ¯\_(ツ)_/¯
- name: Compile (debug)
run: cargo test --workspace --all-features --no-run --target ${{ matrix.settings.target }}
run: cargo build --quiet --workspace --all-features --target ${{ matrix.settings.target }}

- name: Compile (release)
run: cargo test --workspace --all-features --no-run --release --target ${{ matrix.settings.target }}
run: cargo build --quiet --workspace --all-features --release --target ${{ matrix.settings.target }}

- name: Clippy
run: cargo clippy --workspace --all-features --target ${{ matrix.settings.target }}
27 changes: 14 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js, pnpm and dependencies
uses: ./.github/actions/setup-pnpm
Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js, pnpm and dependencies
uses: ./.github/actions/setup-pnpm
Expand All @@ -58,17 +58,17 @@ jobs:
remove-haskell: 'true'
remove-docker-images: 'true'

- name: Checkout repository
uses: actions/checkout@v3

- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path C:\spacedrive_target
New-Item -Path target -ItemType Junction -Value C:\spacedrive_target
- uses: dorny/paths-filter@v2
- name: Checkout repository
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand All @@ -87,6 +87,8 @@ jobs:
- name: Setup Rust and Prisma
if: steps.filter.outputs.changes == 'true'
uses: ./.github/actions/setup-rust
with:
restore-cache: 'false'

- name: Run rustfmt
if: steps.filter.outputs.changes == 'true'
Expand All @@ -110,17 +112,17 @@ jobs:
remove-haskell: 'true'
remove-docker-images: 'true'

- name: Checkout repository
uses: actions/checkout@v3

- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path C:\spacedrive_target
New-Item -Path target -ItemType Junction -Value C:\spacedrive_target
- uses: dorny/paths-filter@v2
- name: Checkout repository
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand All @@ -146,10 +148,9 @@ jobs:

- name: Run Clippy
if: steps.filter.outputs.changes == 'true'
uses: actions-rs/clippy-check@v1
uses: actions-rs-plus/clippy-check@v2
with:
args: --workspace --all-features
token: ${{ secrets.GITHUB_TOKEN }}

# test:
# name: Test (${{ matrix.platform }})
Expand All @@ -159,7 +160,7 @@ jobs:
# platform: [ubuntu-20.04, macos-latest, windows-latest]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# uses: actions/checkout@v4
#
# - name: Setup
# uses: ./.github/actions/setup
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mobile-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:

ios:
name: iOS
runs-on: macos-12
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
version: latest

# - name: Cache Pods
# uses: actions/cache@v3
# uses: actions/cache@v4
# with:
# path: |
# ./apps/mobile/ios/Pods
Expand All @@ -187,7 +187,7 @@ jobs:

- name: Build iOS
working-directory: ./apps/mobile/ios
run: xcodebuild -workspace ./Spacedrive.xcworkspace -scheme Spacedrive -configuration Release -sdk iphonesimulator -derivedDataPath build -arch x86_64
run: xcodebuild -workspace ./Spacedrive.xcworkspace -scheme Spacedrive -configuration Release -sdk iphonesimulator -derivedDataPath build -arch "$(uname -m)"

- name: Install Maestro
run: |
Expand Down
Loading

0 comments on commit 393a907

Please sign in to comment.