Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juristr/tasker-cloud
https://github.com/juristr/tasker-cloud
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/juristr/tasker-cloud
- Owner: juristr
- Created: 2024-09-05T08:59:14.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-07T20:36:48.000Z (2 months ago)
- Last Synced: 2024-09-07T21:38:16.631Z (2 months ago)
- Language: TypeScript
- Size: 404 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tasker
Task management app to demo Nx onboarding.
There is an existing `verify.yml` GitHub Action workflow that will run the following:
```
# Prettier check
pnpm format:check# ESLint
pnpm lint# Next.js
pnpm --filter "@tasker/web" build# Vitest
pnpm --filter "@tasker/*" test# Playwright
pnpm --filter "@tasker/e2e-web" e2e
```Here is my Warp block for reference: https://app.warp.dev/block/UIndYWOJJDLK268mT2f6Xn
The total time in CI is about 26m. With Nx, Nx Cloud, and distribution, that time is cut down to about 8m 30s. Playwright tests go from 24m to 5m 30s, or a 77% improvement.
- BEFORE NX: https://github.com/taskerinc/tasker/actions/runs/9085742807
- AFTER NX: https://github.com/taskerinc/tasker/actions/runs/9142047116This is the worst-case scenario where the changeset affects all projects in the monorepo. The average time will be less than 8m 30s (or 5m 30s for Playwright alone).
## Add Nx CLI
Run this command to start:
```
npx nx@latest init
```For the prompts, answer with the following:
```
npx nx@latest initNX ๐ง Checking dependencies
NX Recommended Plugins:
Add these Nx plugins to integrate with the tools used in your workspace.
โ Which plugins would you like to add? Press to select and to submit. ยท @nx/eslint, @nx/vite, @nx/next, @nx/playwright
โ Do you want to start using Nx in your package.json scripts? ยท Yes
NX ๐ณ Nx initialization
NX ๐งโ๐ง Please answer the following questions about the scripts found in your workspace in order to generate task runner configuration
โ Which scripts need to be run in order? (e.g. before building a project, dependent projects must be built) ยท build, lint, test
โ Which scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not) ยท build, lint, test
โ Does the "build" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage) ยท .next
โ Does the "lint" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage) ยท
โ Does the "test" script create any outputs? If not, leave blank, otherwise provide a path relative to a project root (e.g. dist, lib, build, coverage) ยท
```The answers above will ensure that the correct plugins are installed, and that our existing package scripts are cacheable through Nx.
See my warp run: https://app.warp.dev/block/vMM9pD8Urb0VLk5YfUmK7E
You can skip Nx Cloud for now. Push to CI and see that it runs successfully. The workflow will still be slow since we're not using Nx properly in CI yet.
To enable Nx properly, run `npx nx ci-workflow --ci github`. This will generate a new workflow .yml file. Replace the existing workflow file with the new one:
```
name: CI
on:
push:
branches:
# Change this if your primary branch is not main
- main
pull_request:# Needed for nx-set-shas when run on the main branch
permissions:
actions: read
contents: readjobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
# This line enables distribution
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
# - run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
- run: npm ci- uses: nrwl/nx-set-shas@v4
- run: |
pnpm format:check
pnpm exec nx affected -t lint test build
pnpm exec nx affected -t e2e-ci --parallel 3
```This will ensure that only projects that are affected by current changeset are checked. e.g. if the changeset only includes updates to `README.md`, then no projects will be affected, thus lint/test/etc. are skipped. Using affected brings down the average CI time since not everything needs to be verified.
## Nx Cloud & Distribution
Since we skipped Nx Cloud during `nx init`, run `npx nx connect` to complete the setup.
For distribution to work, uncomment this line in the workflow .yml file:
```
# This line enables distribution
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
- run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
```