Skip to content

Commit

Permalink
Merge branch 'main' into million-3
Browse files Browse the repository at this point in the history
  • Loading branch information
utkubakir committed Mar 26, 2024
2 parents 9d9a8bd + 51acd0f commit 6a27ab4
Show file tree
Hide file tree
Showing 787 changed files with 40,356 additions and 25,347 deletions.
32 changes: 28 additions & 4 deletions .cargo/config.toml.mustache
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
{{#nativeDeps}}
[env]
PROTOC = { force = true, value = "{{{protoc}}}" }
FFMPEG_DIR = { force = true, value = "{{{nativeDeps}}}" }
{{#isLinux}}
ORT_LIB_LOCATION = { force = true, value = "{{{nativeDeps}}}/lib" }
{{/isLinux}}
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 @@ -23,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 @@ -32,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
1 change: 1 addition & 0 deletions .cspell/project_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spacetunnel
specta
storedkey
stringly
thumbstrips
tobiaslutke
typecheck
vdfs
Expand Down
8 changes: 8 additions & 0 deletions .github/actions/publish-artifacts/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: [require.resolve('@sd/config/eslint/base.js')],
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json'
},
ignorePatterns: ['dist/**/*']
};
93 changes: 86 additions & 7 deletions .github/actions/publish-artifacts/dist/index.js

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions .github/actions/publish-artifacts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as artifact from '@actions/artifact';
import client from '@actions/artifact';
import * as core from '@actions/core';
import * as glob from '@actions/glob';
import * as io from '@actions/io';
Expand All @@ -7,29 +7,32 @@ type OS = 'darwin' | 'windows' | 'linux';
type Arch = 'x64' | 'arm64';
type TargetConfig = { bundle: string; ext: string };
type BuildTarget = {
updater: TargetConfig;
updater: { bundle: string; bundleExt: string; archiveExt: string; };
standalone: Array<TargetConfig>;
};

const OS_TARGETS = {
darwin: {
updater: {
bundle: 'macos',
ext: 'app.tar.gz'
bundleExt: 'app',
archiveExt: 'tar.gz'
},
standalone: [{ ext: 'dmg', bundle: 'dmg' }]
},
windows: {
updater: {
bundle: 'msi',
ext: 'msi.zip'
bundleExt: 'msi',
archiveExt: 'zip'
},
standalone: [{ ext: 'msi', bundle: 'msi' }]
},
linux: {
updater: {
bundle: 'appimage',
ext: 'AppImage.tar.gz'
bundleExt: "AppImage",
archiveExt: 'tar.gz'
},
standalone: [
{ ext: 'deb', bundle: 'deb' },
Expand All @@ -49,20 +52,19 @@ const ARTIFACTS_DIR = '.artifacts';
const ARTIFACT_BASE = `Spacedrive-${OS}-${ARCH}`;
const UPDATER_ARTIFACT_NAME = `Spacedrive-Updater-${OS}-${ARCH}`;

const client = artifact.create();

async function globFiles(pattern: string) {
const globber = await glob.create(pattern);
return await globber.glob();
}

async function uploadUpdater({ bundle, ext }: TargetConfig) {
const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${ext}*`);
async function uploadUpdater({ bundle, bundleExt, archiveExt }: BuildTarget["updater"]) {
const fullExt = `${bundleExt}.${archiveExt}`
const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${fullExt}*`);

const updaterPath = files.find((file) => file.endsWith(ext));
const updaterPath = files.find((file) => file.endsWith(fullExt));
if (!updaterPath) return console.error(`Updater path not found. Files: ${files}`);

const artifactPath = `${ARTIFACTS_DIR}/${UPDATER_ARTIFACT_NAME}.${ext}`;
const artifactPath = `${ARTIFACTS_DIR}/${UPDATER_ARTIFACT_NAME}.${archiveExt}`;

// https://tauri.app/v1/guides/distribution/updater#update-artifacts
await io.cp(updaterPath, artifactPath);
Expand Down
10 changes: 6 additions & 4 deletions .github/actions/publish-artifacts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
"name": "@sd/publish-artifacts",
"private": true,
"scripts": {
"build": "ncc build index.ts --minify"
"build": "ncc build index.ts --minify",
"typecheck": "tsc -b",
"lint": "eslint . --cache"
},
"dependencies": {
"@actions/artifact": "^1.1.2",
"@actions/artifact": "^2.1.3",
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@actions/glob": "^0.4.0",
"@actions/io": "^1.1.3"
},
"devDependencies": {
"@vercel/ncc": "^0.38.1"
"@vercel/ncc": "^0.38.1",
"@sd/config": "workspace:*"
}
}
3 changes: 2 additions & 1 deletion .github/actions/publish-artifacts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"noEmit": true
}
}
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
16 changes: 14 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,15 +37,27 @@ 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

- name: Install current Bash on macOS
shell: bash
if: runner.os == 'macOS'
run: brew install bash

- name: Install Nasm
if: ${{ runner.os != 'Linux' }}
uses: ilammy/setup-nasm@v1

- name: Install Mold (linker)
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
34 changes: 26 additions & 8 deletions .github/workflows/cache-factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,32 @@ 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:
fail-fast: true
matrix:
settings:
- host: macos-latest
- host: macos-13
target: x86_64-apple-darwin
- host: macos-latest
- host: macos-14
target: aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
Expand All @@ -46,15 +57,15 @@ jobs:
if: ${{ runner.os == 'Linux' }}
uses: easimon/maximize-build-space@master
with:
swap-size-mb: 3072
swap-size-mb: 4096
root-reserve-mb: 6144
remove-dotnet: 'true'
remove-codeql: 'true'
remove-haskell: 'true'
remove-docker-images: 'true'

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

- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
Expand All @@ -70,11 +81,18 @@ jobs:
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 }}
Loading

0 comments on commit 6a27ab4

Please sign in to comment.