Skip to content

Commit

Permalink
Merge pull request #52 from CrowdStrike/turbo_try2
Browse files Browse the repository at this point in the history
Setup turborepo, second try
  • Loading branch information
simonihmig committed Feb 21, 2023
2 parents ebdd267 + 4c81454 commit b0b2a84
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 136 deletions.
41 changes: 0 additions & 41 deletions .github/actions/assert-build/action.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/actions/download-built-package/action.yml

This file was deleted.

10 changes: 9 additions & 1 deletion .github/actions/pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ runs:
cache: 'pnpm'
- name: 'Install dependencies'
shell: 'bash'
run: pnpm install
run: |
pnpm -v
pnpm install --fix-lockfile
git_diff=$(git diff)
if [[ "$git_diff" -eq "" ]]; then
echo "Success: no lockfile differences" ;
else
echo "Error: lockfile differences detected";
fi
82 changes: 40 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,34 @@ concurrency:

env:
CI: true
# dist: ember-headless-form/dist
TURBO_API: http://127.0.0.1:9080
TURBO_TOKEN: foo-123
TURBO_TEAM: foo

jobs:
install_dependencies:
name: Install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm

# build:
# name: Build Tests
# needs: [install_dependencies]
# timeout-minutes: 5
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/pnpm
# - uses: ./.github/actions/assert-build

lint:
name: Lint
runs-on: ubuntu-latest
needs:
- install_dependencies
# - build
steps:
- uses: actions/checkout@v3
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm
- run: pnpm build && pnpm i -f
# To be able to run glint, we need the dist directory
# - uses: ./.github/actions/download-built-package
- name: Lint + Format + Glint
run: pnpm lint

Expand All @@ -54,7 +50,6 @@ jobs:
timeout-minutes: 3
needs:
- install_dependencies
# - build
continue-on-error: true
strategy:
fail-fast: true
Expand All @@ -65,47 +60,48 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm
# - uses: ./.github/actions/download-built-package
- run: pnpm build && pnpm i -f
- name: 'Change TS to ${{ matrix.typescript-scenario }}'
run: 'pnpm add --save-dev ${{ matrix.typescript-scenario}}'
working-directory: ./test-app
- name: 'Type checking'
run: |
pnpm --filter test-app exec tsc -v;
pnpm --filter test-app exec glint --version;
pnpm --filter test-app exec glint;
run: pnpm turbo typecheck

default_tests:
name: Default Tests
timeout-minutes: 5
runs-on: ubuntu-latest
needs:
- install_dependencies
# - build
steps:
- uses: actions/checkout@v3
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm
- run: pnpm build && pnpm i -f
# - uses: ./.github/actions/download-built-package
- run: pnpm --filter test-app test:ember
- run: pnpm test

floating_tests:
name: Floating Deps Test
timeout-minutes: 5
runs-on: ubuntu-latest
needs:
- install_dependencies
# - build
steps:
- uses: actions/checkout@v3
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm
- name: Install Dependencies (without lockfile)
run: rm pnpm-lock.yaml && pnpm install
- run: pnpm build && pnpm i -f
# - uses: ./.github/actions/download-built-package
- run: pnpm --filter test-app test:ember
- run: pnpm test

try_scenarios:
name: ${{ matrix.try-scenario }}
Expand All @@ -128,14 +124,14 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm
- run: pnpm build && pnpm i -f
# - uses: ./.github/actions/download-built-package
- name: Run Tests
working-directory: ./test-app
run: >-
node_modules/.bin/ember try:one ${{ matrix.try-scenario }}
--skip-cleanup
run: node_modules/.bin/ember try:one ${{matrix.try-scenario}} --skip-cleanup --- pnpm turbo test

# https://github.com/changesets/action
release:
Expand All @@ -153,9 +149,12 @@ jobs:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: TurboRepo local server
uses: felixmosh/turborepo-gh-artifacts@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/pnpm
- run: pnpm build && pnpm i -f
# - uses: ./.github/actions/download-built-package
- run: pnpm build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
Expand All @@ -170,7 +169,8 @@ jobs:
publishDocs:
name: Publish Docs to Cloudflare Pages
runs-on: ubuntu-latest
# needs: build
needs:
- install_dependencies
permissions:
contents: read
deployments: write
Expand All @@ -180,9 +180,7 @@ jobs:
with:
persist-credentials: false
- uses: ./.github/actions/pnpm
- run: pnpm build && pnpm i -f
# - uses: ./.github/actions/download-built-package
- run: pnpm build:docs-app
- run: pnpm build:docs
- name: Publish to Cloudflare Pages
id: publishStep
uses: cloudflare/pages-action@1
Expand All @@ -198,4 +196,4 @@ jobs:
## Preview URLs
Env: ${{ steps.publishStep.outputs.environment }}
Docs: ${{ steps.publishStep.outputs.url }}
# # api docs: ${{ steps.publishStep.outputs.url }}/api/modules.html
# # api docs: ${{ steps.publishStep.outputs.url }}/api/modules.html
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist/
node_modules/

# misc
.turbo/
/.env*
/.pnp*
/.pnpm-debug.log
Expand Down
4 changes: 3 additions & 1 deletion docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"start": "ember serve",
"test:ember": "ember test"
"test:ember": "ember test",
"_syncPnpm": "pnpm sync-pnpm"
},
"devDependencies": {
"@babel/core": "^7.19.6",
Expand Down Expand Up @@ -103,6 +104,7 @@
"prettier-plugin-ember-template-tag": "^0.3.0",
"qunit": "^2.19.1",
"qunit-dom": "^2.0.0",
"sync-pnpm": "workspace:*",
"tailwindcss": "^3.1.8",
"typescript": "^4.8.4",
"webpack": "^5.74.0"
Expand Down
3 changes: 3 additions & 0 deletions internal/sync-pnpm/bin/sync-pnpm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import syncPnpm from '../index.js';

await syncPnpm();
41 changes: 41 additions & 0 deletions internal/sync-pnpm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { join, dirname } from 'node:path';
import { createRequire } from 'node:module';

import { getPackages } from '@manypkg/get-packages';
import { findRoot } from '@manypkg/find-root';
import { readJson, pathExists } from 'fs-extra/esm';
import { hardLinkDir } from '@pnpm/fs.hard-link-dir';
import resolvePackagePath from 'resolve-package-path';

const require = createRequire(import.meta.url);

const syncDir = './dist';

export default async function syncPnpm(dir = process.cwd()) {
const root = await findRoot(dir);
const ownPackageJson = await readJson(join(dir, 'package.json'));
const ownDependencies = [
...Object.keys(ownPackageJson.dependencies ?? {}),
...Object.keys(ownPackageJson.devDependencies ?? {}),
];

const localPackages = (await getPackages(root.rootDir)).packages;

const packagesToSync = localPackages.filter(
(p) =>
p.packageJson.name !== 'sync-pnpm' &&
ownDependencies.includes(p.packageJson.name)
);

for (const pkg of packagesToSync) {
const syncFrom = join(pkg.dir, syncDir);
const resolvedPackagePath = dirname(
resolvePackagePath(pkg.packageJson.name, dir)
);
const syncTo = join(resolvedPackagePath, syncDir);

if (await pathExists(syncFrom)) {
await hardLinkDir(syncFrom, [syncTo]);
}
}
}
19 changes: 19 additions & 0 deletions internal/sync-pnpm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "sync-pnpm",
"version": "0.0.0",
"private": true,
"description": "Sync build artifacts of workspace packages to pnpm injected/hard linked copies",
"repository": "",
"license": "MIT",
"author": "",
"main": "index.js",
"bin": "bin/sync-pnpm.js",
"type": "module",
"dependencies": {
"@manypkg/find-root": "^2.1.0",
"@manypkg/get-packages": "^2.1.0",
"@pnpm/fs.hard-link-dir": "^1.0.3",
"fs-extra": "^11.1.0",
"resolve-package-path": "^4.0.3"
}
}
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
"author": "CrowdStrike UX Team",
"scripts": {
"release": "changeset publish",
"prepare": "pnpm build",
"build": "pnpm --filter ember-headless-form build && pnpm --filter '@ember-headless-form/*' build",
"build:docs-app": "pnpm --filter 'docs-app' build",
"start": "concurrently 'npm:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
"start:tests": "pnpm --filter test-app start",
"build:docs": "pnpm turbo build --filter docs-app",
"start": "pnpm start:tests",
"start:docs": "pnpm turbo --filter docs-app start",
"start:tests": "pnpm turbo --filter test-app start",
"start:addon": "pnpm --filter !test-app start --no-watch.clearScreen",
"test": "pnpm --filter test-app test",
"lint": "pnpm --filter '*' lint",
"build": "pnpm turbo build",
"test": "pnpm turbo --filter test-app test",
"test:docs": "pnpm turbo --filter docs-app test",
"lint": "pnpm turbo lint",
"lint:fix": "pnpm --filter '*' lint:fix"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"concurrently": "^7.6.0",
"prettier": "^2.8.3"
"prettier": "^2.8.3",
"turbo": "^1.7.4"
},
"pnpm": {
"overrides": {
Expand Down

0 comments on commit b0b2a84

Please sign in to comment.