Skip to content

Commit

Permalink
chore: switch to mask + small other fixes
Browse files Browse the repository at this point in the history
Switched to mask as our task runner from Just.
Mask seems to provide a much nicer cli than just and also is much easier
to write than the just files, since its markdown. Ideally they should
add support for submoudles and some things to help with code
duplication. Like global variables, global scripts, cascading flags,
catch all extra arguments, ect... However these are not big enough
issues for us to not use it since just/make is very unmaintainable and very
messy when we have a lot of tasks.

I made an issue on their repo for the submodule idea.
jacobdeichert/mask#96

Some small fixes:
- .gitignores on mac
- prettier not formatting all files
  • Loading branch information
TroyKomodo committed Feb 20, 2023
1 parent f21a818 commit 606624d
Show file tree
Hide file tree
Showing 13 changed files with 689 additions and 165 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ jobs:
curl -L https://github.com/ScuffleTV/ci-binaries/releases/download/sqlx-cli/sqlx-cli.tar.gz | tar -xz -C $CARGO_HOME/bin
- name: Install dependencies
run: just setup-deps
run: mask bootstrap --no-db --no-docker --no-env --no-js-tests --no-stack --no-rust

- name: Run migrations
run: just db-migrate
run: mask db migrate

- name: Run Lint
run: just lint
run: mask lint

- name: Run Test Rust
run: just test-rust
run: mask test --no-js

test-js:
name: Run Tests JavaScript
Expand Down Expand Up @@ -116,16 +116,17 @@ jobs:
restore-keys: |
gnu-rust-test-js-
- uses: taiki-e/install-action@just
- name: Install mask
run: |
curl -L https://github.com/jacobdeichert/mask/releases/download/v0.11.3/mask-v0.11.3-x86_64-unknown-linux-gnu.zip -o mask.zip
unzip mask.zip -d /tmp/mask
mv /tmp/mask/**/mask ~/.cargo/bin/mask
- name: Install dependencies
run: just setup-deps

- name: Setup tests
run: just setup-tests
run: mask bootstrap --no-db --no-docker --no-env --no-stack --no-rust

- name: Run Test JavaScript
run: just test-js
run: mask test --no-rust

build:
name: Run Build
Expand Down Expand Up @@ -167,7 +168,7 @@ jobs:
musl-rust-target-build-
- name: Install dependencies
run: just setup-deps
run: mask bootstrap --no-db --no-docker --no-env --no-js-tests --no-stack --no-rust

- name: Run Build
run: just build
run: mask build
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ target/
!.vscode/extensions.json
node_modules/
.env*
dev-stack/stack.docker-compose.yaml
dev-stack/docker-compose.yml
*.log
.DS_Store
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

just lint
mask lint
51 changes: 25 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You can find instructions on how to do that [here](https://devblogs.microsoft.co
- [Docker](https://www.docker.com/)
- [Docker Compose V2](https://docs.docker.com/compose/install)
- [Rust](https://www.rust-lang.org/tools/install)
- [Just](https://just.systems/)
- [Mask](https://github.com/jacobdeichert/mask)
- [Musl](https://musl.libc.org/)

### For Ubuntu
Expand Down Expand Up @@ -75,10 +75,10 @@ source $HOME/.cargo/env
export PATH="$HOME/.cargo/bin:$HOME/.yarn/bin:$PATH"
```

Installing Just
Installing Mask

```
cargo install just
cargo install mask
```

## Setting up the project
Expand All @@ -88,59 +88,58 @@ Once you have everything installed, you can clone the project and install the de
```bash
git clone --recurse-submodules https://github.com/ScuffleTV/scuffle.git scuffle
cd scuffle
just setup
mask bootstrap
```

The boostrap command will setup the project for you.

This includes:

- Installing all the dependencies
- Setting up the database
- Setting up the local stack
- Setting up .env files

## Development Database

We use Postgres for our database.

You can run a local instance of Postgres with the following command:

```bash
just db-up
mask db up
```

To shut down the local instance of Postgres you can run the following command:

```bash
just db-down
mask db down
```

### Database Migrations

We use sqlx-cli to manage our database migrations.

You can create a new migration with the following command:

```bash
just db-migrate-create <migration-name>
```

Then you can find the SQL for the migration in the [migrations](./backend/migrations) folder.

You can run the migrations with the following command:

```bash
just db-migrate
mask db migrate
```

### Creating Database Migrations

To create a new migration, you can use the `just db-migrate-create` command.
You can create a new migration with the following command:

```bash
just db-migrate-create <migration-name>
mask db migrate add "migration name"
```

This will create a new migration file in the [migrations](./backend/migrations) folder.
Then you can find the SQL for the migration in the [migrations](./backend/migrations) folder.
You can then edit the up migration file to add your SQL.
You must also provide a down migration file so we can rollback the migration.

You will then be prompted to rerun the prepare command

```bash
just db-prepare
mask db prepare
```

This will run the migrations and generate the SQLx code for the database. So that compile time querying can be used.
Expand All @@ -150,28 +149,28 @@ This will run the migrations and generate the SQLx code for the database. So tha
You can setup a local stack with the following command:

```bash
just stack-init
mask stack init
```

You need to have fully built local environment before running this command. You can do that with the following command:

```bash
just build
mask build
```

Or if you want to build it inside a container you can run:

```bash
just build-container
mask build --container
```

Then to start it run

```
just stack-up
mask stack up
```

You can modify the stack by editing `./dev-stack/docker-compose.yaml` file generated by `just stack-init`.
You can modify the stack by editing `./dev-stack/docker-compose.yml` file generated by `mask stack init`.

## Monorepo

Expand Down
107 changes: 0 additions & 107 deletions Justfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "3.1"

name: "db-scuffle-dev"

services:
postgres:
image: postgres:15.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "3.1"

name: "stack-scuffle-dev"

services:
api:
build:
Expand Down
16 changes: 12 additions & 4 deletions docker/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
FROM rust:1.67.1-alpine3.17

RUN <<eot
set -eux

# Install all dependencies for building the backend and frontend

# CVEs fixed in 3.0.8-r0
Expand All @@ -11,15 +13,21 @@ RUN <<eot
apk add --no-cache nodejs=18.14.1-r0 yarn=1.22.19-r0

# We need to install just to use our build script
apk add --no-cache just=1.8.0-r0 musl-dev=1.2.3-r4 curl=7.87.0-r2 git=2.38.4-r0 tar=1.34-r1
apk add --no-cache musl-dev=1.2.3-r4 curl=7.87.0-r2 git=2.38.4-r0 tar=1.34-r1 unzip=6.0-r13 zip=3.0-r10 bash=5.2.15-r0

# Add wasm build target
rustup target add wasm32-unknown-unknown

# Install clippy and rustfmt
rustup component add clippy rustfmt
# Install clippy, rustfmt and llvm-tools-preview
rustup component add clippy rustfmt llvm-tools-preview

curl https://github.com/jacobdeichert/mask/releases/download/v0.11.3/mask-v0.11.3-x86_64-unknown-linux-musl.zip -L -o /tmp/mask.zip
unzip /tmp/mask.zip -d /tmp/mask
mv /tmp/mask/**/mask /usr/local/bin/mask

rm -r /tmp/mask /tmp/mask.zip

# Clean up cache files
rm -r /usr/local/cargo/registry
rm -r /usr/local/cargo/registry || true
yarn cache clean
eot
5 changes: 0 additions & 5 deletions frontend/player/Justfile

This file was deleted.

Loading

0 comments on commit 606624d

Please sign in to comment.