This commit is contained in:
Oscar Beaumont 2022-06-14 22:27:03 +08:00 committed by GitHub
parent fd01e61123
commit 79fa96c3bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 180 additions and 289 deletions

View file

@ -1,60 +0,0 @@
name: Build Server Image
description: Builds and publishes the docker image for the Spacedrive server
inputs:
gh_token:
description: 'A Github PAT'
required: true
runs:
using: 'composite'
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.gh_token }}
- name: Build Server
shell: bash
run: |
cargo build --release -p server
cp ./target/release/server ./apps/server/server
- name: Determine image name & tag
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" == "release" ]; then
export IMAGE_TAG=${GITHUB_REF##*/}
else
export IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA")
fi
export GITHUB_REPOSITORY_LOWER=$(echo $GITHUB_REPOSITORY | awk '{print tolower($0)}')
export IMAGE_NAME="ghcr.io/$GITHUB_REPOSITORY_LOWER/server"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "Building $IMAGE_NAME:$IMAGE_TAG"
- name: Build Docker image
shell: bash
run: |
docker build ./apps/server --tag $IMAGE_NAME:$IMAGE_TAG
- name: Push Docker image
shell: bash
if: github.event_name != 'pull_request'
run: |
docker push $IMAGE_NAME:$IMAGE_TAG
- name: Tag & push image as latest staging image
if: github.event_name != 'release'
shell: bash
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:staging
docker push $IMAGE_NAME:staging
- name: Tag & push image as latest production image
if: github.event_name == 'release'
shell: bash
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:production
docker push $IMAGE_NAME:production

View file

@ -1,44 +0,0 @@
name: Install dependencies
description: Installs OS-specific dependencies for builds
runs:
using: "composite"
steps:
- name: Install ffmpeg & tauri deps (Ubuntu)
if: matrix.platform == 'ubuntu-latest'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libssl-dev \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavresample-dev \
libavutil-dev \
libswscale-dev \
libswresample-dev \
ffmpeg \
libgtk-3-dev \
webkit2gtk-4.0 \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Install ffmpeg (macOS)
if: matrix.platform == 'macos-latest'
shell: bash
run: brew install ffmpeg
- name: Install vcpkg & ffmpeg (Windows)
if: matrix.platform == 'windows-latest'
shell: powershell
run: |
$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
Invoke-WebRequest "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z" -OutFile ffmpeg-release-full-shared.7z
7z x ffmpeg-release-full-shared.7z
mkdir ffmpeg
mv ffmpeg-*/* ffmpeg/
Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg`n"
Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin`n"

View file

@ -1,5 +0,0 @@
name: 'Install ffmpeg macOS'
description: 'Installs ffmpeg with caching for macOS'
runs:
using: 'node16'
main: 'index.js'

View file

@ -1,8 +0,0 @@
// @ts-check
const core = require('@actions/core');
const exec = require('@actions/exec');
const github = require('@actions/github');
// const folders =
exec.exec('brew', ['install', 'ffmpeg']);

View file

@ -1,17 +0,0 @@
{
"name": "install-ffmpeg-macos",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Brendan Allan",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.6.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.0.1"
}
}

View file

@ -1,25 +1,41 @@
name: Publish desktop artifacts
description: Publishes desktop artifacts after Tauri build
name: Publish artifacts
description: Publishes artifacts after CI process
runs:
using: 'composite'
steps:
- name: Make AppImage executable
if: matrix.platform == 'ubuntu-latest'
shell: bash
run: chmod +x ./target/release/bundle/appimage/spacedrive*.AppImage
- name: Determine short GitHub SHA
shell: bash
run: |
export GITHUB_SHA_SHORT=$(git rev-parse --short "$GITHUB_SHA")
echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT" >> $GITHUB_ENV
- name: Set AppImage file permissions & compress it
if: matrix.platform == 'ubuntu-latest'
shell: bash
run: |
chmod +x ./target/release/bundle/appimage/spacedrive*.AppImage
tar -czvf ./Spacedrive-AppImage-${{ env.GITHUB_SHA_SHORT }}.tar.gz ./target/release/bundle/appimage/spacedrive*.AppImage
- name: Publish artifacts (AppImage)
if: matrix.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: Spacedrive-AppImage-${{ env.GITHUB_SHA_SHORT }}
path: ./target/release/bundle/appimage/spacedrive*.AppImage
path: ./Spacedrive-AppImage-${{ env.GITHUB_SHA_SHORT }}.tar.gz
- name: Publish artifacts (deb)
if: matrix.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: Spacedrive-deb-${{ env.GITHUB_SHA_SHORT }}
path: ./target/release/bundle/deb/spacedrive*.deb
- name: Publish artifacts (server)
if: matrix.platform == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: Spacedrive-server-${{ env.GITHUB_SHA_SHORT }}
path: ./target/release/server
- name: Publish artifacts (Windows)
if: matrix.platform == 'windows-latest'

10
.github/scripts/setup-system.ps1 vendored Normal file
View file

@ -0,0 +1,10 @@
Write-Host "This script is currently being used by CI and will need some more work before anyone can use it like the 'setup-system.sh' script for macOS and Linux!"
$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
Invoke-WebRequest "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z" -OutFile ffmpeg-release-full-shared.7z
7z x ffmpeg-release-full-shared.7z
mkdir ffmpeg
mv ffmpeg-*/* ffmpeg/
Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg`n"
Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin`n"

View file

@ -1,5 +1,7 @@
#!/bin/bash
set -e
echo "Setting up your system for Spacedrive development!"
which cargo &> /dev/null
@ -20,9 +22,9 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libappindicator3-dev librsvg2-dev" # Tauri dependencies
DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFMPEG dependencies
DEBIAN_BINDGEN_DEPS="pkg-config clang" # Bindgen dependencies - it's used by a dependency of Spacedrive
sudo apt-get -y update
sudo apt-get -y install $DEBIAN_TAURI_DEPS $DEBIAN_FFMPEG_DEPS $DEBIAN_BINDGEN_DEPS
sudo apt-get -y install ${CUSTOM_APT_FLAGS:-} $DEBIAN_TAURI_DEPS $DEBIAN_FFMPEG_DEPS $DEBIAN_BINDGEN_DEPS
elif which pacman &> /dev/null; then
echo "Detected 'pacman' based distro!"
ARCH_TAURI_DEPS="webkit2gtk base-devel curl wget openssl appmenu-gtk-module gtk3 libappindicator-gtk3 librsvg libvips" # Tauri deps https://tauri.studio/guides/getting-started/setup/linux#1-system-dependencies
@ -52,4 +54,4 @@ else
echo "Your OS '$OSTYPE' is not supported by this script. We would welcome a PR or some help adding your OS to this script. https://github.com/spacedriveapp/spacedrive/issues"
exit 1
fi
fi

View file

@ -5,13 +5,13 @@ on:
push:
branches:
- main
- new-ci
paths-ignore:
- '**/.md'
workflow_dispatch:
env:
CARGO_INCREMENTAL: 1
CUSTOM_APT_FLAGS: --no-install-recommends
jobs:
typescript:
@ -21,7 +21,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 17
@ -30,142 +30,58 @@ jobs:
uses: pnpm/action-setup@v2.2.2
with:
version: 7.x.x
run_install: false
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install pnpm dependencies
run: pnpm --frozen-lockfile i
- name: Perform typechecks
run: pnpm typecheck
build-js:
name: Build JS
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 17
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 7.x.x
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build Desktop
run: pnpm desktop build
- name: Build Web
run: pnpm web build
build-core:
name: Build Core (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
needs: typescript
strategy:
fail-fast: true
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Log in to the Container registry
if: matrix.platform == 'ubuntu-latest' && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-deps
- name: Setup Node
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 17
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, rust-src
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }}
- name: Generate Prisma client
working-directory: core
run: cargo run -p prisma-cli --release -- generate
- name: Build Core
run: cargo build -p sdcore --release
package-desktop:
name: Package desktop (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
needs: [typescript, build-js, build-core]
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-deps
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 17
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, rust-src
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }}
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
uses: pnpm/action-setup@v2.0.1
with:
version: 7.x.x
- name: Install pnpm dependencies
run: pnpm i --frozen-lockfile
- name: Build frontend
run: pnpm desktop build
- name: Generate Prisma client
working-directory: core
run: cargo run -p prisma-cli --release -- generate
- name: Bundle
run: pnpm desktop tauri build
- name: Publish artifacts
uses: ./.github/actions/publish-desktop-artifacts
build-server:
name: Build server
runs-on: ubuntu-latest
needs: build-core
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-deps
version: 7
run_install: false
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
@ -173,31 +89,96 @@ jobs:
profile: minimal
override: true
components: rustfmt, rust-src
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
sharedKey: core-v1-${{ hashFiles('**/Cargo.lock') }}
- name: Run 'setup-system.sh' script
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest'
run: ./.github/scripts/setup-system.sh
- name: Run 'setup-system.ps1' script
if: matrix.platform == 'windows-latest'
run: ./.github/scripts/setup-system.ps1
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install pnpm dependencies
run: pnpm --frozen-lockfile i
- name: Cache Prisma codegen
id: cache-prisma
uses: actions/cache@v3
with:
path: ./core/src/prisma.rs
key: prisma-${{ hashFiles('./core/prisma/Cargo.toml', './core/prisma/schema.prisma', './core/prisma/src/main.rs') }}
- name: Generate Prisma client
working-directory: core
run: cargo run -p prisma-cli --release -- generate
if: steps.cache-prisma.outputs.cache-hit != 'true'
run: cargo run --frozen --locked -p prisma-cli --release -- generate
- name: Build server image
uses: ./.github/actions/build-server-image
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
- name: Cargo fetch
run: cargo fetch --frozen
deploy-server:
name: Deploy Server
runs-on: ubuntu-latest
needs: build-server
if: github.event_name != 'pull_request'
steps:
- name: Deploy Spacedrive Server to Kubernetes
env:
K8S_KUBECONFIG: ${{ secrets.K8S_KUBECONFIG }}
- name: Check Core
run: cargo check --frozen --offline -p sdcore --release
- name: Bundle Desktop
run: pnpm desktop tauri build
- name: Build Server
if: matrix.platform == 'ubuntu-latest'
run: |
mkdir -p ~/.kube
echo "$K8S_KUBECONFIG" > ~/.kube/config 2>&1
kubectl rollout restart deployment/sdserver-deployment
cargo build --frozen --offline -p server --release
cp ./target/release/server ./apps/server/server
- name: Determine image name & tag
if: matrix.platform == 'ubuntu-latest' && github.event_name != 'pull_request'
run: |
if [ "$GITHUB_EVENT_NAME" == "release" ]; then
export IMAGE_TAG=${GITHUB_REF##*/}
else
export IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA")
fi
export GITHUB_REPOSITORY_LOWER=$(echo $GITHUB_REPOSITORY | awk '{print tolower($0)}')
export IMAGE_NAME="ghcr.io/$GITHUB_REPOSITORY_LOWER/server"
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "Building $IMAGE_NAME:$IMAGE_TAG"
- name: Build Docker image
if: matrix.platform == 'ubuntu-latest' && github.event_name != 'pull_request'
run: |
docker build ./apps/server --tag $IMAGE_NAME:$IMAGE_TAG
- name: Push Docker image
if: matrix.platform == 'ubuntu-latest' && github.event_name != 'pull_request'
run: |
docker push $IMAGE_NAME:$IMAGE_TAG
- name: Tag & push image as latest staging image
if: matrix.platform == 'ubuntu-latest' && github.event_name != 'pull_request' && github.event_name != 'release'
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:staging
docker push $IMAGE_NAME:staging
- name: Tag & push image as latest production image
if: matrix.platform == 'ubuntu-latest' && github.event_name == 'release'
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:production
docker push $IMAGE_NAME:production
- name: Publish artifacts
uses: ./.github/actions/publish-artifacts

21
.github/workflows/clippy.yml vendored Normal file
View file

@ -0,0 +1,21 @@
name: Rust Clippy check
on:
pull_request:
push:
paths:
- '**.rs'
workflow_dispatch:
jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features

View file

@ -1,15 +1,18 @@
name: Create diagram
on:
workflow_dispatch: {}
push:
branches:
- main
workflow_dispatch:
jobs:
get_data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Update diagram
uses: githubocto/repo-visualizer@main
with:

View file

@ -8,7 +8,7 @@ repository = "https://github.com/spacedriveapp/spacedrive"
edition = "2021"
[features]
p2p = ["dep:libp2p"] # This feature controlls whether the Spacedrive Core contains the Peer to Peer syncing engine (It isn't required for the hosted core so we can disable it).
p2p = [] # This feature controlls whether the Spacedrive Core contains the Peer to Peer syncing engine (It isn't required for the hosted core so we can disable it).
[dependencies]
hostname = "0.3.1"
@ -27,7 +27,6 @@ int-enum = "0.4.0"
ts-rs = { version = "6.1", features = ["chrono-impl"] }
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.5.0" }
walkdir = "^2.3.2"
libp2p = { version = "0.43.0", optional = true }
lazy_static = "1.4.0"
uuid = "0.8"
sysinfo = "0.23.9"
@ -39,6 +38,5 @@ include_dir = {version = "0.7.2", features = ["glob"]}
async-trait = "0.1.52"
image = "0.24.1"
webp = "0.2.2"
uhlc = "0.4.1"
ffmpeg-next = "5.0.3"
fs_extra = "1.2.0"

View file

@ -164,11 +164,6 @@ impl Node {
internal_channel,
};
#[cfg(feature = "p2p")]
tokio::spawn(async move {
p2p::listener::listen(None).await.unwrap_or(());
});
(node, event_recv)
}

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 192 KiB