Skip to content

Commit

Permalink
chore(ci): use self-hosted runner (#92)
Browse files Browse the repository at this point in the history
* aw shit, here we go again

* blindly testing

* ugh

* ugh x2

* ugh x3

* could scream

* :)

* haha

* ???

* HAHAHAHAHA

* stinky

* smellz

* 😠

* hmmm

* oops

* y no werk :sad:

* testing arm

* testing arm oops

* tweaks

* tweaks

* fix conditions

* test cache

* try fix cache

* try fix cache again

* test cache again

* test just core change

* try ignore

* pause on caching ig 😭

* add cancelling?

* hrm

* ugh, figure something else out for cancelling...

* push up yesterdays stuff oops

* ugh

* ugh

* just for now

* sigh

* HUH?

* maybe?

* wrapping this up

* wrapping this up x2
  • Loading branch information
aaronleopold authored Mar 11, 2023
1 parent 87fc414 commit 0e79aec
Show file tree
Hide file tree
Showing 31 changed files with 607 additions and 195 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ dist
static
apps/server/client
target
*.lock
*-lock.*
*.log
*.db
.git

# ignore contents in excess directories, some are kept only so cargo
# doesn't yell at me
Expand Down
37 changes: 37 additions & 0 deletions .github/actions/build-desktop/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Build Stump desktop app'
description: 'Compile the Stump desktop app'

inputs:
platform:
description: 'The plaform of the runner'
required: true

runs:
using: composite
steps:
- name: Checkout project
uses: actions/checkout@v3

# - name: Configure environment
# run: |
# if [[ ${{ inputs.platform }} == 'linux' || ${{ inputs.platform }} == 'windows' ]]; then
# echo "RUN_SETUP=false" >> $GITHUB_ENV
# else
# echo "RUN_SETUP=true" >> $GITHUB_ENV
# fi

- name: Setup rust
uses: ./.github/actions/setup-cargo

- name: Generate Prisma client
uses: ./.github/actions/setup-prisma

- name: Copy bundled web app
uses: actions/download-artifact@v3
with:
name: webapp
path: ./apps/desktop/dist

- name: Compile desktop app
shell: bash
run: cargo build --package stump_desktop --release
97 changes: 97 additions & 0 deletions .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: 'Build docker image'
description: 'Build and load or push a tagged docker image for stump'

inputs:
username:
description: 'Username for docker login'
required: true
password:
description: 'Token for docker login'
required: true
load:
description: 'Set output-type to docker'
default: true
push:
description: 'Set output-type to registry'
default: false
tags:
description: 'List of tags to assigned to the image'
default: 'nightly'
platforms:
description: 'List of platforms to build'
required: true

runs:
using: composite
steps:
- name: Get commit short sha
run: echo "GIT_REV=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
shell: bash

- name: Format tags
run: |
echo "TAGS=$(echo ${{ inputs.tags }} | sed -e 's/,/,aaronleopold\/stump:/g' | sed -e 's/^/aaronleopold\/stump:/')" >> $GITHUB_ENV
shell: bash

- name: Setup rust
uses: ./.github/actions/setup-cargo

- name: Generate Prisma client
uses: ./.github/actions/setup-prisma

# TODO: uncomment once cache stuff is resolved...
# - name: Setup Docker layers cache
# uses: actions/cache@v3
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-

# We only need QEMU when an arm* platform is targeted
- name: Check QEMU requirement
id: check-qemu
run: |
if [[ ${{ inputs.platforms }} == *"arm"* ]]; then
echo "SETUP_QEMU=1" >> $GITHUB_OUTPUT
else
echo "SETUP_QEMU=0" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: ${{ steps.check-qemu.outputs.SETUP_QEMU == '1' }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Run buildx build
uses: docker/build-push-action@v4
with:
context: .
build-args: |
"GIT_REV=${{ env.GIT_REV }}"
file: scripts/release/Dockerfile
platforms: ${{ inputs.platforms }}
load: ${{ inputs.load }}
push: ${{ inputs.push }}
tags: ${{ env.TAGS }}
# TODO: uncomment once cache stuff is resolved...
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# https://github.com/docker/build-push-action/issues/252
# TODO: https://github.com/moby/buildkit/issues/1896
# TODO: uncomment once cache stuff is resolved...
# - name: Move buildx cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# shell: bash
29 changes: 17 additions & 12 deletions .github/actions/build-server/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'Compile rust'
description: 'Compile stump rust server'
name: 'Build Stump server'
description: 'Compile the Stump Rust server'

inputs:
platform:
description: 'runner plaform'
description: 'The plaform of the runner'
required: true

runs:
Expand All @@ -12,21 +12,26 @@ runs:
- name: Checkout project
uses: actions/checkout@v3

# - name: Configure environment
# run: |
# if [[ ${{ inputs.platform }} == 'linux' || ${{ inputs.platform }} == 'windows' ]]; then
# echo "RUN_SETUP=false" >> $GITHUB_ENV
# else
# echo "RUN_SETUP=true" >> $GITHUB_ENV
# fi

- name: Setup rust
uses: ./.github/actions/setup-system
uses: ./.github/actions/setup-cargo

- name: Generate Prisma client
uses: ./.github/actions/setup-prisma
- name: Download frontend

- name: Copy bundled web app
uses: actions/download-artifact@v3
with:
name: web
name: webapp
path: ./apps/server/dist

- name: Copy web app to tauri
run: cp -r ./apps/server/dist apps/desktop/dist
shell: bash

- name: Build server
- name: Compile server
shell: bash
run: cargo build --release
run: cargo build --package stump_server --release
27 changes: 20 additions & 7 deletions .github/actions/build-web/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
name: 'Build Web Application'
description: "Build web application and upload it's artifacts"
name: 'Compile Web Application'
description: 'Compile stump web'

runs:
using: 'composite'
using: composite
steps:
- name: Build
uses: ./.github/actions/compile-web
- name: Checkout project
uses: actions/checkout@v3

- name: Upload
- name: Setup pnpm
uses: ./.github/actions/setup-pnpm

- name: Install dependencies
shell: bash
run: pnpm install
working-directory: apps/web

- name: Build app
shell: bash
run: pnpm run build
working-directory: apps/web

- name: Upload bundle
uses: ./.github/actions/upload-artifact
with:
upload-name: web
upload-name: webapp
upload-path: apps/web/dist
20 changes: 0 additions & 20 deletions .github/actions/compile-web/action.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/actions/setup-cargo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ description: 'Install system dependencies and setup cache'
runs:
using: 'composite'
steps:
- name: Configure environment
run: |
if [[ ${{ runner.name }} == 'manjaro-az' || ${{ runner.os }} == 'Windows' ]]; then
echo "RUN_SETUP=false" >> $GITHUB_ENV
else
echo "RUN_SETUP=true" >> $GITHUB_ENV
fi
shell: bash

- name: System setup
if: ${{ env.RUN_SETUP == 'true' }}
shell: bash
run: CHECK_NODE=0 CHECK_CARGO=0 DEV_SETUP=0 ./scripts/system-setup.sh

Expand Down
4 changes: 2 additions & 2 deletions .github/actions/setup-prisma/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
key: ${{ runner.os }}-prisma-${{ hashFiles('**/schema.prisma') }}

- name: Generate Prisma client
working-directory: core
# working-directory: core
if: steps.cache-prisma.outputs.cache-hit != 'true'
shell: bash
run: cargo run -p prisma --release -- generate
run: cargo prisma generate --schema=./core/prisma/schema.prisma
1 change: 0 additions & 1 deletion .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: 'Upload Local'
description: 'Upload artifact to local action'

inputs:
# Upload
upload-name:
required: true
description: 'Name of the upload'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_nix.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Build legacy Nix package on Ubuntu"
name: 'Stump Nix CI'

on:
push:
Expand All @@ -15,5 +15,5 @@ jobs:
- uses: cachix/install-nix-action@v17
- name: test
run: nix develop --command "pkg-config" "--libs" "--cflags" "gdk-3.0" "gdk-3.0 >= 3.22"
# - name: Building package
# - name: Building package
# run: nix develop --command pnpm core run setup && cargo check
50 changes: 10 additions & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: Stump-CI
name: 'Stump Checks CI'

on:
pull_request:
push:
branches:
- main

# TODO: figure out how to use moon here.
jobs:
check-rust:
name: Rust checks
runs-on: ubuntu-latest
# TODO: remove this once I have my own, hosted runner...
if: github.ref == 'refs/heads/main'
runs-on: [self-hosted]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -26,52 +25,23 @@ jobs:
run: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
- name: Run tests
run: |
cargo integration-tests
# TODO: fix the tests, then uncomment this
# - name: Run tests
# run: |
# cargo integration-tests

check-typescript:
name: TypeScript checks
runs-on: ubuntu-latest
runs-on: [self-hosted]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup pnpm and typescript
- name: Setup PNPM and TypeScript
uses: ./.github/actions/setup-pnpm

- name: lint
- name: Run TypeScript lints
run: pnpm lint

# - name: typecheck
# run: pnpm moon run :typecheck

# release:
# name: Release (${{ matrix.platform }})
# runs-on: ${{ matrix.platform }}
# # Release only runs on push to main. TODO: can I make this trigger on tag?
# if: github.event_name != 'pull_request'
# strategy:
# fail-fast: true
# matrix:
# platform: [ubuntu-latest, macos-latest, windows-latest]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
# override: true
# # TODO: clippy??
# components: rustfmt, rust-src

# # TODO: figure out caching for rust deps

# - name: Generate Prisma client
# uses: ./.github/actions/generate-prisma-client

# TODO: pnpm setup
# TODO: docker builds -> maybe this helps? https://github.com/devture/matrix-corporal/blob/master/.gitlab-ci.yml
Loading

0 comments on commit 0e79aec

Please sign in to comment.