Skip to content

Commit

Permalink
Merge pull request #10 from clemenscodes/feature/ci
Browse files Browse the repository at this point in the history
feature/ci
  • Loading branch information
clemenscodes authored Feb 13, 2024
2 parents 25fac9b + b5f0002 commit fc8bc6f
Show file tree
Hide file tree
Showing 38 changed files with 306 additions and 1,398 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

layout node
watch_file rust-toolchain.toml
use flake
112 changes: 112 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main, develop]
types: [opened, synchronize]

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

env:
NEXT_TELEMETRY_DISABLED: 1
CI: true

jobs:
ci:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Checkout [Main]
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
fetch-depth: 0

- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: pnpm cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-

- name: cargo cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/dist
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: nextjs cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/**/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install

- name: Install Rust
uses: moonrepo/setup-rust@v1

- name: Install Tauri Dependencies
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev
- name: Format
run: pnpm fmt:check

- name: Lint
run: pnpm lint:affected --nx-bail --base=$NX_BASE --head=$NX_HEAD

- name: Build
run: pnpm build:affected --nx-bail --base=$NX_BASE --head=$NX_HEAD --exclude ui

- name: Test
run: pnpm test:affected --nx-bail --base=$NX_BASE --head=$NX_HEAD

cleanup:
name: Cleanup
runs-on: ubuntu-latest
needs: [ci]
steps:
- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: "*"
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ coverage
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Next.js
**/.next
**/out
**/gen
10 changes: 0 additions & 10 deletions apps/e2e/.eslintrc.json

This file was deleted.

13 changes: 0 additions & 13 deletions apps/e2e/cypress.config.ts

This file was deleted.

8 changes: 0 additions & 8 deletions apps/e2e/project.json

This file was deleted.

13 changes: 0 additions & 13 deletions apps/e2e/src/e2e/app.cy.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/e2e/src/fixtures/example.json

This file was deleted.

1 change: 0 additions & 1 deletion apps/e2e/src/support/app.po.ts

This file was deleted.

35 changes: 0 additions & 35 deletions apps/e2e/src/support/commands.ts

This file was deleted.

17 changes: 0 additions & 17 deletions apps/e2e/src/support/e2e.ts

This file was deleted.

20 changes: 0 additions & 20 deletions apps/e2e/tsconfig.json

This file was deleted.

25 changes: 17 additions & 8 deletions apps/gui/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,24 @@
}
},
"test": {
"executor": "@monodon/rust:test",
"outputs": ["{options.target-dir}"],
"cache": true,
"executor": "nx:run-commands",
"options": {
"target-dir": "dist/apps/gui"
},
"configurations": {
"production": {
"release": true
}
"color": true,
"env": {
"CARGO_INCREMENTAL": "0",
"RUSTFLAGS": "-Cinstrument-coverage",
"LLVM_PROFILE_FILE": "../../coverage/apps/{projectName}/%p-%m.profraw"
},
"command": "cargo test -p {projectName} --lib --target-dir dist/apps/{projectName}"
}
},
"coverage": {
"cache": true,
"dependsOn": ["test"],
"executor": "nx:run-commands",
"options": {
"command": "grcov . --binary-path ./dist/apps/{projectName}/debug/deps/ -s apps/{projectName} -t lcov --branch --ignore-not-existing --ignore '../*' --ignore '/*' -o coverage/apps/{projectName}/tests.lcov"
}
},
"lint": {
Expand Down
2 changes: 1 addition & 1 deletion apps/gui/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"identifier": "draken.chess",
"build": {
"beforeDevCommand": "pnpm nx dev ui",
"beforeBuildCommand": "pnpm nx build ui",
"beforeBuildCommand": "pnpm nx build ui --skip-nx-cache",
"devUrl": "http://localhost:3000",
"frontendDist": "../../dist/apps/ui"
},
Expand Down
1 change: 1 addition & 0 deletions apps/ui/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export default {
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
coverageDirectory: "../../coverage/ui",
passWithNoTests: true,
};
3 changes: 3 additions & 0 deletions apps/ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module.exports = async (phase, { defaultConfig }) => {
images: {
unoptimized: true,
},
typescript: {
ignoreBuildErrors: true,
},
assetPrefix: isProd ? undefined : `http://${internalHost}:3000`,
};
return composePlugins(...plugins)(nextConfig)();
Expand Down
39 changes: 38 additions & 1 deletion apps/ui/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,43 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "ui",
"projectType": "application",
"targets": {},
"targets": {
"build": {
"executor": "nx:run-commands",
"inputs": ["default", "^default"],
"outputs": ["{workspaceRoot}/dist/apps/ui"],
"options": {
"color": true,
"cwd": "apps/{projectName}",
"command": "next build"
}
},
"test": {
"executor": "nx:run-commands",
"inputs": ["default", "^default"],
"options": {
"color": true,
"cwd": "apps/{projectName}",
"command": "jest"
}
},
"start": {
"executor": "nx:run-commands",
"options": {
"color": true,
"cwd": "apps/{projectName}",
"command": "next start"
}
},
"lint": {
"executor": "nx:run-commands",
"inputs": ["default", "^default"],
"options": {
"color": true,
"cwd": "apps/{projectName}",
"command": "eslint ."
}
}
},
"tags": []
}
1 change: 0 additions & 1 deletion apps/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"**/*.jsx",
"next-env.d.ts",
".next/types/**/*.ts",
"../../dist/apps/ui/types/**/*.ts",
],
"exclude": [
"node_modules",
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc8bc6f

Please sign in to comment.