From eed03b39af0f662fc49d7f7aac683bc766a428a4 Mon Sep 17 00:00:00 2001 From: wuweiweiwu Date: Mon, 25 Nov 2024 12:37:12 -0800 Subject: [PATCH] reorganize into separate directories --- .github/workflows/test-amazon-linux.yml | 8 ++++---- .github/workflows/test-pr-inputs.yml | 5 ++++- .github/workflows/test-pr-multi-project.yml | 8 ++++---- .github/workflows/test-pr-sharding.yml | 5 ++++- .github/workflows/test-pr.yml | 5 ++++- .github/workflows/test-prod.yml | 5 ++++- README.md | 13 ++++++++++--- .../apps/dashboard/google-search.test.yaml | 0 .../apps/dashboard/momentic.config.yaml | 0 .../apps/marketing/momentic.config.yaml | 0 .../apps/marketing/variable-showcase.test.yaml | 0 .../common/practice-test-login.module.yaml | 0 .../momentic.workspace.yaml | 1 - .../qa/momentic.config.yaml | 0 .../qa/practice-test-login.test.yaml | 0 .../test.env | 0 .../create-react-app-test.test.yaml | 0 {momentic => single-project}/data/inputs.csv | 0 {momentic => single-project}/google-test.test.yaml | 0 .../input-from-csv-test.test.yaml | 0 .../momentic.config.yaml | 2 -- 21 files changed, 34 insertions(+), 18 deletions(-) rename {multi-project-workspace-example => multi-project-workspace}/apps/dashboard/google-search.test.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/apps/dashboard/momentic.config.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/apps/marketing/momentic.config.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/apps/marketing/variable-showcase.test.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/common/practice-test-login.module.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/momentic.workspace.yaml (98%) rename {multi-project-workspace-example => multi-project-workspace}/qa/momentic.config.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/qa/practice-test-login.test.yaml (100%) rename {multi-project-workspace-example => multi-project-workspace}/test.env (100%) rename {momentic => single-project}/create-react-app-test.test.yaml (100%) rename {momentic => single-project}/data/inputs.csv (100%) rename {momentic => single-project}/google-test.test.yaml (100%) rename {momentic => single-project}/input-from-csv-test.test.yaml (100%) rename momentic.config.yaml => single-project/momentic.config.yaml (83%) diff --git a/.github/workflows/test-amazon-linux.yml b/.github/workflows/test-amazon-linux.yml index 7a71205..f40ea8b 100644 --- a/.github/workflows/test-amazon-linux.yml +++ b/.github/workflows/test-amazon-linux.yml @@ -7,7 +7,7 @@ on: push: branches: - main - + jobs: run-tests-on-amazon-linux: name: Run tests @@ -61,7 +61,7 @@ jobs: # Run tests cat momentic.config.yaml - npx momentic@^1 run momentic/google-test.test.yaml + npx momentic@latest run google-test.test.yaml EOF @@ -73,8 +73,8 @@ jobs: run: | docker run -d --name momentic --network host -e MOMENTIC_API_KEY='${{ secrets.MOMENTIC_API_KEY }}' ubuntu:20.04 sleep infinity docker cp run_tests.sh momentic:/run_tests.sh - docker cp momentic.config.yaml momentic:/momentic.config.yaml - docker cp momentic momentic:/ + docker cp single-project/momentic.config.yaml momentic:/momentic.config.yaml + docker cp single-project/ momentic:/ docker exec momentic bash /run_tests.sh # Section 5: Cleanup diff --git a/.github/workflows/test-pr-inputs.yml b/.github/workflows/test-pr-inputs.yml index 72488e2..85b4bd9 100644 --- a/.github/workflows/test-pr-inputs.yml +++ b/.github/workflows/test-pr-inputs.yml @@ -15,6 +15,9 @@ jobs: repository-projects: read strategy: fail-fast: false + defaults: + run: + working-directory: ./single-project steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 @@ -24,4 +27,4 @@ jobs: with: node-version: 21 cache: "pnpm" - - run: npx momentic@^1 run --input-csv momentic/data/inputs.csv momentic/input-from-csv-test.test.yaml + - run: npx momentic@latest run --input-csv data/inputs.csv input-from-csv-test.test.yaml diff --git a/.github/workflows/test-pr-multi-project.yml b/.github/workflows/test-pr-multi-project.yml index 64f6151..59097dd 100644 --- a/.github/workflows/test-pr-multi-project.yml +++ b/.github/workflows/test-pr-multi-project.yml @@ -15,7 +15,7 @@ jobs: repository-projects: read defaults: run: - working-directory: ./multi-project-workspace-example + working-directory: ./multi-project-workspace steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 @@ -28,12 +28,12 @@ jobs: - name: Install dependencies run: pnpm i - name: Run specific marketing tests using project name and substring match - run: npx momentic@^1 run --filter marketing variable + run: npx momentic@latest run --filter marketing variable env: VAR_FROM_SHELL: test-var-from-shell - name: Run all QA tests using config path - run: npx momentic@^1 run --config qa/momentic.config.yaml . + run: npx momentic@latest run --config qa/momentic.config.yaml . - name: Run dashboard tests using absolute path run: | cd apps/dashboard - npx momentic@^1 run google-search.test.yaml \ No newline at end of file + npx momentic@latest run google-search.test.yaml diff --git a/.github/workflows/test-pr-sharding.yml b/.github/workflows/test-pr-sharding.yml index 2666c1f..71a9124 100644 --- a/.github/workflows/test-pr-sharding.yml +++ b/.github/workflows/test-pr-sharding.yml @@ -18,6 +18,9 @@ jobs: matrix: shardIndex: [1, 2] shardTotal: [2] + defaults: + run: + working-directory: ./single-project steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 @@ -30,7 +33,7 @@ jobs: - name: Install dependencies run: pnpm i - run: | - npx momentic@^1 run momentic/create-react-app-test.test.yaml \ + npx momentic@latest run create-react-app-test.test.yaml \ --start "npm run start" \ --env development \ --shard-index ${{ matrix.shardIndex }} \ diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index dba6b61..7327ff2 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -13,6 +13,9 @@ jobs: permissions: contents: read repository-projects: read + defaults: + run: + working-directory: ./single-project steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 @@ -24,4 +27,4 @@ jobs: cache: "pnpm" - name: Install dependencies run: pnpm i - - run: npx momentic@^1 run momentic/create-react-app-test.test.yaml --start "npm run start" --env development + - run: npx momentic@latest run create-react-app-test.test.yaml --start "npm run start" --env development diff --git a/.github/workflows/test-prod.yml b/.github/workflows/test-prod.yml index d61ff04..4f77433 100644 --- a/.github/workflows/test-prod.yml +++ b/.github/workflows/test-prod.yml @@ -15,9 +15,12 @@ jobs: permissions: contents: read repository-projects: read + defaults: + run: + working-directory: ./single-project steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 21 - - run: npx momentic@^1 queue tests create-react-app-test + - run: npx momentic@latest queue tests create-react-app-test diff --git a/README.md b/README.md index 3460c62..efe101d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # Momentic GitHub Actions demo -This repo uses the [Momentic CLI](https://docs.momentic.ai/cli/installation) to: +This repo contains usage examples and patterns for the [Momentic CLI](https://momentic.ai/docs/cli/v1/installation). -1. Trigger Momentic cloud test runs on every push to `main`. -2. Run local tests against a local React app on every pull request. +- [Workspace](multi-project-workspace/) +- [Project](single-project/) +- CI/CD workflows + - [Amazon Linux](.github/workflows/test-amazon-linux.yml) + - [CSV inputs](.github/workflows/test-pr-inputs.yml) + - [Multiple projects](.github/workflows/test-pr-multi-project.yml) + - [Sharding](.github/workflows/test-pr-sharding.yml) + - [Run in a PR](.github/workflows/test-pr.yml) + - [Queue in cloud](.github/workflows/test-prod.yml) diff --git a/multi-project-workspace-example/apps/dashboard/google-search.test.yaml b/multi-project-workspace/apps/dashboard/google-search.test.yaml similarity index 100% rename from multi-project-workspace-example/apps/dashboard/google-search.test.yaml rename to multi-project-workspace/apps/dashboard/google-search.test.yaml diff --git a/multi-project-workspace-example/apps/dashboard/momentic.config.yaml b/multi-project-workspace/apps/dashboard/momentic.config.yaml similarity index 100% rename from multi-project-workspace-example/apps/dashboard/momentic.config.yaml rename to multi-project-workspace/apps/dashboard/momentic.config.yaml diff --git a/multi-project-workspace-example/apps/marketing/momentic.config.yaml b/multi-project-workspace/apps/marketing/momentic.config.yaml similarity index 100% rename from multi-project-workspace-example/apps/marketing/momentic.config.yaml rename to multi-project-workspace/apps/marketing/momentic.config.yaml diff --git a/multi-project-workspace-example/apps/marketing/variable-showcase.test.yaml b/multi-project-workspace/apps/marketing/variable-showcase.test.yaml similarity index 100% rename from multi-project-workspace-example/apps/marketing/variable-showcase.test.yaml rename to multi-project-workspace/apps/marketing/variable-showcase.test.yaml diff --git a/multi-project-workspace-example/common/practice-test-login.module.yaml b/multi-project-workspace/common/practice-test-login.module.yaml similarity index 100% rename from multi-project-workspace-example/common/practice-test-login.module.yaml rename to multi-project-workspace/common/practice-test-login.module.yaml diff --git a/multi-project-workspace-example/momentic.workspace.yaml b/multi-project-workspace/momentic.workspace.yaml similarity index 98% rename from multi-project-workspace-example/momentic.workspace.yaml rename to multi-project-workspace/momentic.workspace.yaml index 0db251f..4e51dba 100644 --- a/multi-project-workspace-example/momentic.workspace.yaml +++ b/multi-project-workspace/momentic.workspace.yaml @@ -2,4 +2,3 @@ projects: - qa # immediate children directories of apps - apps/* - diff --git a/multi-project-workspace-example/qa/momentic.config.yaml b/multi-project-workspace/qa/momentic.config.yaml similarity index 100% rename from multi-project-workspace-example/qa/momentic.config.yaml rename to multi-project-workspace/qa/momentic.config.yaml diff --git a/multi-project-workspace-example/qa/practice-test-login.test.yaml b/multi-project-workspace/qa/practice-test-login.test.yaml similarity index 100% rename from multi-project-workspace-example/qa/practice-test-login.test.yaml rename to multi-project-workspace/qa/practice-test-login.test.yaml diff --git a/multi-project-workspace-example/test.env b/multi-project-workspace/test.env similarity index 100% rename from multi-project-workspace-example/test.env rename to multi-project-workspace/test.env diff --git a/momentic/create-react-app-test.test.yaml b/single-project/create-react-app-test.test.yaml similarity index 100% rename from momentic/create-react-app-test.test.yaml rename to single-project/create-react-app-test.test.yaml diff --git a/momentic/data/inputs.csv b/single-project/data/inputs.csv similarity index 100% rename from momentic/data/inputs.csv rename to single-project/data/inputs.csv diff --git a/momentic/google-test.test.yaml b/single-project/google-test.test.yaml similarity index 100% rename from momentic/google-test.test.yaml rename to single-project/google-test.test.yaml diff --git a/momentic/input-from-csv-test.test.yaml b/single-project/input-from-csv-test.test.yaml similarity index 100% rename from momentic/input-from-csv-test.test.yaml rename to single-project/input-from-csv-test.test.yaml diff --git a/momentic.config.yaml b/single-project/momentic.config.yaml similarity index 83% rename from momentic.config.yaml rename to single-project/momentic.config.yaml index cd73ba5..d1b2b84 100644 --- a/momentic.config.yaml +++ b/single-project/momentic.config.yaml @@ -2,8 +2,6 @@ name: default include: - "**/*.test.yaml" - "**/*.module.yaml" -exclude: - - "multi-project-workspace-example/**/*" environments: - name: development baseUrl: https://momentic-github-actions-demo.vercel.app/