Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/cms/composer.lock
#	packages/drupal/silverback_ai/modules/silverback_image_ai/README.md
#	packages/drupal/test_content/content/node/a397ca48-8fad-411e-8901-0eba2feb989c.yml
  • Loading branch information
Leksat committed Dec 4, 2024
2 parents 34868e3 + 4cc812c commit 6212520
Show file tree
Hide file tree
Showing 73 changed files with 294 additions and 3,050 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: Test
on:
push:
workflow_dispatch:
inputs:
turborepo_caching:
description: 'Turborepo caching'
type: choice
options:
- 'On'
- 'Off'
default: 'On'

jobs:
test:
Expand All @@ -25,6 +34,7 @@ jobs:
run: pnpm test:format

- name: TurboRepo local server
if: ${{ github.event.inputs.turborepo_caching != 'Off' }}
uses: felixmosh/turborepo-gh-artifacts@v2
with:
server-token: 'local'
Expand Down
53 changes: 0 additions & 53 deletions .github/workflows/test_without_turbo_cache.yml

This file was deleted.

62 changes: 1 addition & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,67 +127,7 @@ Navigate to an app/package folder and run `pnpm dev`.
When working on integration tasks, it may be required to re-run
`pnpm turbo:prep` from the repo root.

### Turborepo

<details>
<summary>How it works in general</summary>

Turborepo allows to cache results for scripts from `package.json` files.

Minimal example:

- The `build` script compiles files from `src` folder and puts the result into
`dist` folder
- We can setup a Turborepo pipeline
```json
"build": {
"inputs": ["src/**"],
"outputs": ["dist/**"]
}
```
- On the first `turbo build` run Turborepo will
- calculate hashes for files from `src` folder, and save them into cache,
- save `dist` folder into cache.
- On the second `turbo build` run Turborepo will compare `src` hashes with
cache. If hashes do match, it will restore `dist` folder from the cache
without running the `build` script.

More in docs: https://turbo.build/repo/docs/core-concepts/caching

</details>

<details>
<summary>Turborepo setup: local vs CI</summary>

Locally, Turborepo stores caches under `node_modules/.cache/turbo` folder.

In CI, the caches are saved in Github artifacts.

</details>

<details>
<summary>Debug Turborepo issues in CI</summary>

It can happen that some script fails in CI because of a misconfigured Turborepo
pipeline. The following can be used in order to debug this locally:

- Setup https://github.com/ducktors/turborepo-remote-cache locally
- Run `turborepo-remote-cache` with `TURBO_TOKEN=local pnpm dev`
- Run tests in the target repo with

```shell
# Clean the repo
rm -rf node_modules && git clean -dxff -e '/.turbo' -e '_local' -e '/.idea' && find . -type d -empty -delete && \
# Install dependencies
pnpm i && \
# Run tests with
# - local Turborepo server
# - Turborepo debug info
# - simulated CI
TURBO_API=http://0.0.0.0:3000 TURBO_TOKEN=local TURBO_TEAM=local TURBO_RUN_SUMMARY=true CI=true pnpm turbo:test
```

</details>
More info on Turborepo: [docs/turborepo.md](docs/turborepo.md).

### Drupal

Expand Down
1 change: 1 addition & 0 deletions apps/cms/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"amazeelabs/default-content": "^1.2.11",
"amazeelabs/graphql_directives": "^2.4",
"amazeelabs/silverback-cli": "^2.9.13",
"amazeelabs/silverback_ai": "^1.1",
"amazeelabs/silverback_autosave": "^1.1",
"amazeelabs/silverback_campaign_urls": "^1.0.5",
"amazeelabs/silverback_cloudinary": "^1.3.0",
Expand Down
40 changes: 33 additions & 7 deletions apps/cms/composer.lock

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

14 changes: 14 additions & 0 deletions apps/cms/prep-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ fi
# In any case, re-import translation string.
pnpm import-translations
pnpm drush cr

# On CI, run the content export and check if the export is up to date.
if [ ! -z $GITHUB_ACTIONS ]; then
pnpm content:export
if [[ $(git status --porcelain) ]]; then
echo "Error: Content export is not up to date"
echo "Please run 'pnpm content:export' from apps/cms and commit the changes"
echo "Detected changes:"
git status --porcelain
echo "Diff:"
git diff
exit 1
fi
fi
2 changes: 1 addition & 1 deletion apps/cms/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"web/sites/default/files/**",
"../../packages/ui/static/stories/webforms/**"
],
"env": ["CI", "LAGOON", "SKIP_DRUPAL_INSTALL"]
"env": ["CI", "LAGOON", "SKIP_DRUPAL_INSTALL", "GITHUB_ACTIONS"]
},
"prep:composer": {
"inputs": ["composer.json", "composer.lock", "scaffold/**", "patches/**"],
Expand Down
50 changes: 50 additions & 0 deletions docs/turborepo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## How it works in general

Turborepo allows to cache results for scripts from `package.json` files.

Minimal example:

- The `build` script compiles files from `src` folder and puts the result into
`dist` folder
- We can setup a Turborepo pipeline
```json
"build": {
"inputs": ["src/**"],
"outputs": ["dist/**"]
}
```
- On the first `turbo build` run Turborepo will
- calculate hashes for files from `src` folder, and save them into cache,
- save `dist` folder into cache.
- On the second `turbo build` run Turborepo will compare `src` hashes with
cache. If hashes do match, it will restore `dist` folder from the cache
without running the `build` script.

More in docs: https://turbo.build/repo/docs/core-concepts/caching

## Turborepo setup: local vs CI

Locally, Turborepo stores caches in `.turbo` folder.

In CI, the caches are saved in Github artifacts.

## Debug Turborepo issues in CI

It can happen that some script fails in CI because of a misconfigured Turborepo
pipeline. The following can be used in order to debug this locally:

- Setup https://github.com/ducktors/turborepo-remote-cache locally
- Run `turborepo-remote-cache` with `TURBO_TOKEN=local pnpm dev`
- Run tests in the target repo with

```shell
# Clean the repo
devbox run clean
# Install dependencies
pnpm i
# Run tests with
# - local Turborepo server
# - Turborepo debug info
# - simulated CI
TURBO_API=http://0.0.0.0:3000 TURBO_TOKEN=local TURBO_TEAM=local TURBO_RUN_SUMMARY=true CI=true pnpm turbo:test
```
30 changes: 0 additions & 30 deletions packages/drupal/silverback_ai/README.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6212520

Please sign in to comment.