Skip to content

Commit

Permalink
open source Lapdev
Browse files Browse the repository at this point in the history
  • Loading branch information
lyang2821 committed Mar 23, 2024
0 parents commit 3cb1271
Show file tree
Hide file tree
Showing 150 changed files with 37,275 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dockerComposeFile": "docker-compose.yml",
"service": "lapdev",
}
6 changes: 6 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'
services:
lapdev:
image: mcr.microsoft.com/devcontainers/rust:latest
db:
image: docker.io/postgres:latest
110 changes: 110 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

name: CI

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

env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
build:
name: Rust on ${{ matrix.os }} (${{ join(matrix.features, ',') }})
if: github.event.pull_request.draft == false
needs: [fmt, clippy]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

# - name: Install dependencies on Ubuntu
# if: startsWith(matrix.os, 'ubuntu')
# run: sudo apt-get update && sudo apt-get install clang libxkbcommon-x11-dev pkg-config libvulkan-dev libgtk-3-dev libwayland-dev xorg-dev libxcb-shape0-dev libxcb-xfixes0-dev

- name: Update toolchain & add llvm-tools
run: |
rustup update
rustup component add llvm-tools-preview
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Fetch dependencies
run: cargo fetch --locked

- name: Build guest agent
run: cargo build -p lapdev-guest-agent --release --frozen

- name: Create lapdev-dashboard/dist folder
run: mkdir -p lapdev-dashboard/dist

- name: Build
run: cargo build -p lapdev --frozen

- name: Build ws
run: cargo build -p lapdev-ws --frozen

- name: Run tests
run: cargo test --workspace

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Update toolchain & add rustfmt
run: |
rustup update
rustup component add rustfmt
- name: Run rustfmt
run: cargo fmt --all --check

clippy:
name: Clippy on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Update toolchain & add clippy
run: |
rustup update
rustup component add clippy
# - name: Install dependencies on Ubuntu
# if: startsWith(matrix.os, 'ubuntu')
# run: sudo apt-get update && sudo apt-get install clang libxkbcommon-x11-dev pkg-config libvulkan-dev libwayland-dev xorg-dev libxcb-shape0-dev libxcb-xfixes0-dev

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Fetch dependencies
run: cargo fetch --locked

- name: Create lapdev-dashboard/dist folder
run: mkdir -p lapdev-dashboard/dist

- name: Build lapdev-guest-agent
run: cargo build -p lapdev-guest-agent --release --locked

- name: Run clippy
run: cargo clippy -- -D warnings
103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Release
on:
workflow_dispatch:
inputs:
lapdev_version:
description: "Lapdev version for release"
required: true
push:
tags:
- "v*"

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Update toolchain
run: |
rustup update
rustup target add wasm32-unknown-unknown
- name: Install cargo-deb
run: cargo install cargo-deb --no-default-features

- name: Install cargo-generate-rpm
run: cargo install cargo-generate-rpm

- name: Install trunk
run: cargo install --locked trunk

- name: Fetch dependencies
run: cargo fetch --locked

- name: Build wasm
run: cd lapdev-dashboard && trunk build --release --public-url /static/

- name: Compress static files
run: cd lapdev-dashboard/dist/ && gzip -k *

- name: Build lapdev-guest-agent
run: cargo build -p lapdev-guest-agent --release --locked

- name: Build lapdev
run: |
cargo build -p lapdev --release --locked
strip -s target/release/lapdev
- name: Build lapdev-ws
run: |
cargo build -p lapdev-ws --release --locked
strip -s target/release/lapdev-ws
- name: Build lapdev rpm
run: cargo generate-rpm

- name: Build lapdev-ws rpm
run: cargo generate-rpm -p lapdev-ws

- name: Build lapdev deb
run: cargo deb -p lapdev

- name: Build lapdev-ws deb
run: cargo deb -p lapdev-ws

- uses: actions/upload-artifact@v4
with:
name: lapdev-linux
path: |
./target/generate-rpm/lapdev-${{ github.event.inputs.lapdev_version }}-1.x86_64.rpm
./target/generate-rpm/lapdev-ws-${{ github.event.inputs.lapdev_version }}-1.x86_64.rpm
./target/debian/lapdev_${{ github.event.inputs.lapdev_version }}-1_amd64.deb
./target/debian/lapdev-ws_${{ github.event.inputs.lapdev_version }}-1_amd64.deb
./pkg/common/install.sh
./pkg/common/install-ws.sh
retention-days: 1

publish:
runs-on: ubuntu-latest
needs: [linux]
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4

- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=v${{ github.event.inputs.lapdev_version }}" >> $GITHUB_ENV

- name: Publish release
if: github.event_name != 'pull_request'
run: |
gh release create $TAG_NAME --title "$TAG_NAME" --target $GITHUB_SHA \
lapdev-linux/*/*/*
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target
/lapdev-dashboard/dist
.lapce
.env
Loading

0 comments on commit 3cb1271

Please sign in to comment.