Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tauri build and old CI pipeline for publishing tauri #27

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
env:
EARTHLY_TOKEN: ${{ secrets.EARTHLY_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
FORCE_COLOR: 1
steps:
- uses: earthly/actions-setup@v1
with:
version: v0.7.23
- uses: actions/checkout@v2
- name: Docker Login
run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN"
- name: Run build
run: earthly --org applied-knowledge-systems --sat my-satellite --ci --push +docker_all

build-and-test:
name: Build and Test
runs-on: ubuntu-latest
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "publish"
on:
push:
branches:
- release

jobs:
publish-tauri:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 16
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
- name: install app dependencies and build it
run: yarn && yarn build
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "App v__VERSION__"
releaseBody: "See the assets to download this version and install."
releaseDraft: true
prerelease: false
31 changes: 31 additions & 0 deletions .github/workflows/test-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "test-on-pr"
on: [pull_request]

jobs:
test-tauri:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 16
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
- name: install app dependencies and build it
run: yarn && yarn build
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Cargo.lock
*.pdb
.vscode/
terraphim-grep/
artifact
53 changes: 48 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
name = "terraphim_ai"
version = "0.1.0"
edition = "2021"
default-run="terraphim-server"
rust-version = "1.75"
license = "Apache-2.0"
default-run="terraphim_server"
repository = "https://github.com/terraphim/terraphim-ai/"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
Expand All @@ -18,10 +21,40 @@ members = [
"terraphim_types"
]

[dependencies]
tokio = { version = "1.35.1", features = ["fs", "macros", "rt-multi-thread", "rt"] }
itertools = "0.12.0"
opendal = { version = "0.41.0", features = ["services-dashmap", "services-redis", "services-sled","rustls","services-redis-rustls"] }
terraphim_config={path="crates/config"}
terraphim_pipeline={path="crates/terraphim_pipeline"}
terraphim_types= {path="terraphim_types"}
terraphim_settings={path="crates/settings"}
persistance = {path="crates/persistance"}
terraphim_middleware={path="crates/middleware"}
terraphim_server = {path="server-axum"}
anyhow = "1.0.44"
# FIXME: port picker used in axum and desktop
portpicker = "0.1"
rustls-pemfile = "2.0.0"
[dev-dependencies]
reqwest = {version = "0.11", features = ["json","rustls-tls"]}
tokio = { version = "1", features = ["full"] }
serde_json = "1.0.108"


[workspace.dependencies]
tokio = { version = "1.35.1", features = ["fs", "macros", "rt-multi-thread"] }
itertools = "0.11.0"
opendal = { version = "0.41.0", features = ["services-dashmap", "services-redis", "services-sled"] }
tokio = { version = "1.35.1", features = ["fs", "macros", "rt-multi-thread", "rt"] }

[workspace.package]
name = "terraphim_ai"
homepage = "https://terraphim.ai/"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
license = "Apache-2.0"
default-run="terraphim_server"
repository = "https://github.com/terraphim/terraphim-ai/"
authors = ["Alex Mikhalev [email protected]"]


[dependencies.clap]
Expand All @@ -31,5 +64,15 @@ version = "4"
[[bin]]
bench = false
path = "server-axum/src/main.rs"
name = "terraphim-server"
name = "terraphim_server"

[workspace.lints.rust]
unsafe_code = "forbid"

[lints]
workspace = true

[features]
default=["rustls"]

rustls = ["reqwest/rustls-tls-native-roots"]
124 changes: 124 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
VERSION --try --global-cache 0.7
PROJECT applied-knowledge-systems/terraphim-project
IMPORT ./desktop AS desktop
IMPORT github.com/earthly/lib/rust AS rust
FROM ubuntu:20.04

ARG TARGETARCH
ARG TARGETOS
ARG TARGETPLATFORM
ARG --global tag=$TARGETOS-$TARGETARCH
ARG --global TARGETARCH
IF [ "$TARGETARCH" = amd64 ]
ARG --global ARCH=x86_64
ELSE
ARG --global ARCH=$TARGETARCH
END

WORKDIR /code

pipeline:
BUILD desktop+build
BUILD +fmt
BUILD +lint
BUILD +test
BUILD +build


# Creates a `./artifact/bin` folder with all binaries
build-all:
BUILD +build # x86_64-unknown-linux-gnu
BUILD +cross-build --TARGET=x86_64-unknown-linux-musl
BUILD +cross-build --TARGET=armv7-unknown-linux-musleabihf
BUILD +cross-build --TARGET=aarch64-unknown-linux-musl
# Errors
# BUILD +cross-build --TARGET=aarch64-apple-darwin

docker-all:
BUILD --platform=linux/amd64 +docker-musl --TARGET=x86_64-unknown-linux-musl
BUILD --platform=linux/arm/v7 +docker-musl --TARGET=armv7-unknown-linux-musleabihf
BUILD --platform=linux/arm64/v8 +docker-musl --TARGET=aarch64-unknown-linux-musl

install:
FROM rust:1.75.0-buster
RUN apt-get update -qq
RUN apt install -y musl-tools musl-dev
RUN update-ca-certificates
RUN rustup component add clippy
RUN rustup component add rustfmt
RUN cargo install cross
DO rust+INIT --keep_fingerprints=true

source:
FROM +install
COPY --keep-ts Cargo.toml Cargo.lock ./
COPY --keep-ts --dir server-axum desktop crates terraphim_types ./
COPY desktop+build/dist /code/server-axum/dist
DO rust+CARGO --args=fetch

cross-build:
FROM +source
ARG --required TARGET
DO rust+SET_CACHE_MOUNTS_ENV
WITH DOCKER
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE cross build --target $TARGET --release
END
DO rust+COPY_OUTPUT --output=".*" # Copies all files to ./target
RUN ./target/$TARGET/release/terraphim-server --version
SAVE ARTIFACT ./target/$TARGET/release/terraphim-server AS LOCAL artifact/bin/terraphim_server-$TARGET

build:
FROM +source
DO rust+CARGO --args="build --offline --release" --output="release/[^/\.]+"
RUN ./target/release/terraphim_server --version
SAVE ARTIFACT ./target/release/terraphim_server AS LOCAL artifact/bin/terraphim_server-$TARGET

test:
FROM +source
DO rust+CARGO --args="test"

fmt:
FROM +source
DO rust+CARGO --args="fmt --check"

lint:
FROM +source
DO rust+CARGO --args="clippy --no-deps --all-features --all-targets"

docker-musl:
FROM alpine:3.18
# You can pass multiple tags, space separated
# SAVE IMAGE --push ghcr.io/applied-knowledge-systems/terraphim-fastapiapp:bionic
ARG tags="ghcr.io/applied-knowledge-systems/terraphim-server:latest"
ARG --required TARGET
COPY --chmod=0755 --platform=linux/amd64 (+cross-build/terraphim_server --TARGET=${TARGET}) /terraphim_server
RUN /terraphim_server --version
ENV TERRAPHIM_SERVER_HOSTNAME="127.0.0.1:8000"
ENV TERRAPHIM_SERVER_API_ENDPOINT="http://localhost:8000/api"
EXPOSE 8000
ENTRYPOINT ["/terraphim_server"]
SAVE IMAGE --push ${tags}

docker-aarch64:
FROM rust:latest

RUN apt update && apt upgrade -y
RUN apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross

RUN rustup target add aarch64-unknown-linux-gnu
RUN rustup toolchain install stable-aarch64-unknown-linux-gnu

WORKDIR /app

ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++

CMD ["cargo", "build","--release","--target", "aarch64-unknown-linux-gnu"]

docker-slim:
FROM debian:buster-slim
COPY +build/terraphim_server terraphim_server
EXPOSE 8000
ENTRYPOINT ["./terraphim_server"]
SAVE IMAGE aks/terraphim_server:buster
2 changes: 1 addition & 1 deletion crates/terraphim_automata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
aho-corasick = "1.0.2"
csv = "1.2.2"
flate2 = "1.0.26"
reqwest = { version="0.11.18", features=["json"]}
reqwest = { version="0.11.18", features=["json","rustls-tls"]}
serde = { version = "1.0.163", features = ["derive"] }
thiserror = "1.0.30"
serde_json="1"
Expand Down
Loading
Loading