Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Migrate to moon-repo
Browse files Browse the repository at this point in the history
* ci(react-ui): migrate project to use moon

* ci(main-db): migrate project to use moon

* ci: migrate website and react-ui to moon

* ci: migrate to using moon

* style(protobuf): remove needless borrow

* ci(main-db): add command to lint target

* ci: remove files from eslint and jest

* ci: remove last references to nrwl

Also bring back the commit scripts.

* ci: fail clippy check on warnings

* ci(devcontainer): install moon globally in development environment

* ci(moon): remove typecheck task

* ci(moon): configure local tasks

This enables us to use the `moon check` command that does things parallely.

* refactor(website): use path alias for imports

* ci(main-db): add empty line between tasks

* ci(moon): use noop command to make commands do nothing
  • Loading branch information
IgnisDa authored Oct 29, 2022
1 parent 163da97 commit e36b9d8
Show file tree
Hide file tree
Showing 90 changed files with 1,864 additions and 6,182 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN printf '#!/bin/sh\nexport PATH=$PATH:$HOME/.cargo/bin\n' >> /etc/profile.d/c
chmod +x /etc/profile.d/cargo.sh

RUN set -eu ;\
npm install --global pnpm ;\
npm install --global pnpm @moonrepo/cli ;\
curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh -s -- -y --no-modify-path --verbose ;\
mv "/root/.local/bin/edgedb" "/usr/local/bin/edgedb" ;\
chmod +x "/usr/local/bin/edgedb" ;\
Expand Down
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
*.min.js
*.map
*.snap
dts
coverage
jest.config.*
dbschema
build
dist
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
extends: ['moon'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'no-console': 'error',
'no-await-in-loop': 'off',
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
};
35 changes: 0 additions & 35 deletions .eslintrc.json

This file was deleted.

12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
dist
/tmp
/out-tsc

Expand All @@ -27,11 +27,14 @@ node_modules
# misc
/.sass-cache
/connect.lock
/coverage
coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log

# Types
dts
/typings

# System Files
Expand All @@ -44,3 +47,8 @@ Thumbs.db

# edgedb
libs/main-db/dbschema/edgeql-js

# Moon
.moon/cache
.moon/docker

30 changes: 3 additions & 27 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

two_commits_ago="$(git log --format="%H" -n 2 | tail -n 1)"
# check if remotes exist
if [ "$(git remote)" ]; then
branch_exists=$(git ls-remote --heads origin $(git branch --show-current))
# if branch_exists is empty, then the branch does not exist in the remote
if [ -z "$branch_exists" ]; then
# use $two_commits_ago if the current branch does not exist in the remote
last_remote_commit=$two_commits_ago
else
# a remote may exist but it might not have commits, so we will use the last local one
last_remote_commit=$(git rev-parse origin/"$(git branch --show-current)") || $two_commits_ago
fi
fi
last_local_commit=$(git log --format="%H" -n 1 | tail -n 1)
# detect force push, ref: https://github.com/kyanny/git-hooks-detect-force-update
if [ "$(git rev-list "$last_remote_commit" ^"$last_local_commit")" ]; then
echo "Force push detected..."
last_remote_commit="$two_commits_ago"
fi
echo "Setting base=\"$last_remote_commit\" and head=\"$last_local_commit\""
for target in "lint" "build" "test"; do
pnpm nx affected \
--base="$last_remote_commit" \
--target="$target" \
--nx-bail \
--parallel=6
done
cargo clippy -- -D warnings

moon check "website" "react-ui" "generated" "main-db"
37 changes: 37 additions & 0 deletions .moon/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# https://moonrepo.dev/docs/config/global-project
$schema: 'https://moonrepo.dev/schemas/global-project.json'

tasks:
lint:
command:
- 'eslint'
- '--ext'
- '.js,.jsx,.ts,.tsx'
- '--fix'
- '--report-unused-disable-directives'
- '--no-error-on-unmatched-pattern'
- '--exit-on-fatal-error'
- '--ignore-path'
- '@in(4)'
- '.'
inputs:
- 'src/**/*'
- 'tests/**/*'
- '*.config.*'
- '**/.eslintrc.*'
- '/.eslintignore'
- '/.eslintrc.*'
- 'types/**/*'
- 'tsconfig.json'
- '/tsconfig.eslint.json'
- '/tsconfig.options.json'

test:
command:
- 'jest'
- '--coverage'
- '--passWithNoTests'
inputs:
- 'src/**/*'
- 'tests/**/*'
- 'jest.config.*'
93 changes: 93 additions & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# https://moonrepo.dev/docs/config/workspace
$schema: 'https://moonrepo.dev/schemas/workspace.json'

# Extend and inherit an external configuration file. Must be a valid HTTPS URL or file system path.
# extends: './shared/workspace.yml'

# REQUIRED: A map of all projects found within the workspace, or a list or file system globs.
# When using a map, each entry requires a unique project ID as the map key, and a file system
# path to the project folder as the map value. File paths are relative from the workspace root,
# and cannot reference projects located outside the workspace boundary.
projects:
website: 'apps/website'
generated: 'libs/generated'
main-db: 'libs/main-db'
react-ui: 'libs/react-ui'

# Configures Node.js within the toolchain. moon manages its own version of Node.js
# instead of relying on a version found on the host machine. This ensures deterministic
# and reproducible builds across any machine.
node:
# The version to use. Must be a semantic version that includes major, minor, and patch.
# We suggest using the latest active LTS version: https://nodejs.org/en/about/releases
version: '19.0.0'

# The package manager to use when managing dependencies.
# Accepts "npm" (default), "pnpm", or "yarn".
packageManager: 'pnpm'

# The version of the package manager (above) to use.
pnpm:
version: '7.14.0'

# Add `node.version` as a constraint in the root `package.json` `engines`.
addEnginesConstraint: true

# Use the `package.json` name as an alias for the respective moon project.
# aliasPackageNames: 'name-and-scope'

# Dedupe dependencies after the lockfile has changed.
dedupeOnLockfileChange: true

# Version format to use when syncing dependencies within the project's `package.json`.
# dependencyVersionFormat: 'workspace'

# Infer and automatically create moon tasks from `package.json` scripts, per project.
# BEWARE: Tasks and scripts are not 1:1 in functionality, so please refer to the documentation.
# inferTasksFromScripts: false

# Sync a project's `dependsOn` as dependencies within the project's `package.json`.
syncProjectWorkspaceDependencies: true

# Sync `node.version` to a 3rd-party version manager's config file.
# Accepts "nodenv" (.node-version), "nvm" (.nvmrc), or none.
# syncVersionManagerConfig: 'nvm'

# Configures how moon integrates with TypeScript.
typescript:
# When `syncProjectReferences` is enabled and a dependent project reference
# *does not* have a `tsconfig.json`, automatically create one.
createMissingConfig: true

# Name of `tsconfig.json` file in the project root.
# projectConfigFileName: 'tsconfig.json'

# Name of `tsconfig.json` file in the workspace root.
# rootConfigFileName: 'tsconfig.json'

# Name of the config file in the workspace root that defines shared compiler options
# for all project reference based config files.
# rootOptionsConfigFileName: 'tsconfig.options.json'

# Update the project's `tsconfig.json` to route the `outDir` to moon's cache.
# routeOutDirToCache: true

# Sync a project's `dependsOn` as TypeScript project references within the
# project's `tsconfig.json` and the workspace root `tsconfig.json`.
syncProjectReferences: true

# Sync a project's project references as `paths` aliases.
# syncProjectReferencesToPaths: true

# Configures the version control system to utilize within the workspace. A VCS
# is required for determining touched (added, modified, etc) files, calculating file hashes,
# computing affected files, and much more.
vcs:
# The manager/binary to use when managing the repository.
# Accepts "git", or "svn". Defaults to "git".
manager: 'git'

# The default branch (master/main/trunk) in the repository for comparing the
# local branch against. For git, this is is typically "master" or "main",
# and must include the remote prefix (before /). For svn, this should always be "trunk".
defaultBranch: 'origin/main'
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"magicstack.edgedb",
"tamasfe.even-better-toml",
Expand All @@ -18,6 +17,7 @@
"firsttris.vscode-jest-runner",
"ms-vscode.cpptools",
"zxh404.vscode-proto3",
"rvest.vs-code-prettier-eslint"
"rvest.vs-code-prettier-eslint",
"moonrepo.moon-console"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"emcc",
"emscripten",
"endl",
"esdl",
"farem",
"fstream",
"graphiql",
Expand All @@ -34,7 +35,6 @@
"makepkg",
"nextest",
"nextui",
"nrwl",
"pacman",
"paru",
"pnpm",
Expand All @@ -43,6 +43,7 @@
"protobuf",
"protolint",
"protos",
"rimraf",
"rustc",
"rustup",
"tailwindcss",
Expand Down
30 changes: 15 additions & 15 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"label": "cpp-compiler",
"type": "shell",
"isBackground": true,
"command": "pnpm nx run compilers:run --bin cpp-compiler --watch",
"command": "cargo watch -cqx 'run --bin cpp-compiler'",
"detail": "Run the cpp compiler service",
"options": {
"env": {
Expand All @@ -30,7 +30,7 @@
"label": "go-compiler",
"type": "shell",
"isBackground": true,
"command": "pnpm nx run compilers:run --bin go-compiler --watch",
"command": "cargo watch -cqx 'run --bin go-compiler'",
"detail": "Run the go compiler service",
"options": {
"env": {
Expand All @@ -39,46 +39,46 @@
},
},
{
"label": "orchestrator",
"label": "rs-compiler",
"type": "shell",
"isBackground": true,
"command": "cargo watch -cqx 'run --package orchestrator'",
"detail": "Run the orchestrator service",
"command": "cargo watch -cqx 'run --bin rs-compiler'",
"detail": "Run the rust compiler service",
"options": {
"env": {
"ROCKET_PORT": "8000"
"PORT": "5001"
}
},
},
{
"label": "rs-compiler",
"label": "executor",
"type": "shell",
"isBackground": true,
"command": "pnpm nx run compilers:run --bin rs-compiler --watch",
"detail": "Run the rust compiler service",
"command": "cargo watch -cqx 'run --package executor'",
"detail": "Run the wasm execution service",
"options": {
"env": {
"PORT": "5001"
"PORT": "5004"
}
},
},
{
"label": "executor",
"label": "orchestrator",
"type": "shell",
"isBackground": true,
"command": "cargo watch -cqx 'run --package executor'",
"detail": "Run the wasm execution service",
"command": "cargo watch -cqx 'run --package orchestrator'",
"detail": "Run the orchestrator service",
"options": {
"env": {
"PORT": "5004"
"ROCKET_PORT": "8000"
}
},
},
{
"label": "website",
"type": "shell",
"isBackground": true,
"command": "pnpm nx start website",
"command": "moon run website:dev website:dev-routes",
"detail": "Run the main website server",
"options": {},
},
Expand Down
Loading

0 comments on commit e36b9d8

Please sign in to comment.