-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add migrate github action * trigger on PR * action update * action update * action update * action update * action update * action update * action update * action update * action update * action update * action update * action update * action update * action update * action update * update e2e workflow * Add note in contributing guide * Fail e2e script when e2es fail
- Loading branch information
1 parent
4200eda
commit 9eb7512
Showing
5 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Run e2e tests | ||
|
||
on: | ||
pull_request: | ||
types: [synchronize, opened, reopened] | ||
|
||
jobs: | ||
e2e: | ||
runs-on: ubuntu-latest | ||
name: Run e2e tests | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Use pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 6.0.2 | ||
|
||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: E2E script | ||
id: e2e-run | ||
run: node e2e.js | ||
|
||
- name: Report failure | ||
if: ${{ failure() && github.repository_owner == 'nrwl' && github.event_name != 'workflow_dispatch' }} | ||
uses: ravsamhq/notify-slack-action@v2 | ||
with: | ||
status: 'failure' | ||
message_format: '{emoji} Workflow has {status_message} ${{ steps.e2e-run.outcome }}' | ||
notification_title: '{workflow}' | ||
footer: '<{run_url}|View Run> / Last commit <{commit_url}|{commit_sha}>' | ||
mention_groups: '@Isaac' | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Migrate Recipes | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
|
||
jobs: | ||
migrate-recipes: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
name: Migrate Recipes | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Use pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 6.0.2 | ||
|
||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Migrate script | ||
run: node migrate.js | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
base: main | ||
title: Nx Migrate update | ||
body: Update all recipes with nx migrate | ||
commit-message: migrate recipes | ||
branch: migrate-recipes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { execSync } = require("child_process"); | ||
const { readdirSync } = require("fs"); | ||
|
||
const BROKEN_RECIPES = [".git", ".github", "deno-deploy"]; | ||
|
||
function installPackages(cwd) { | ||
const files = readdirSync(cwd); | ||
if (files.includes("pnpm-lock.yaml")) { | ||
execSync("pnpm i", { cwd }); | ||
} else if (files.includes("yarn-lock.json")) { | ||
execSync("yarn", { cwd }); | ||
} else { | ||
execSync("npm i --legacy-peer-deps", { cwd }); | ||
} | ||
} | ||
|
||
function runE2eTests(cwd) { | ||
execSync("CI=true npx nx run-many --target=e2e --parallel=false", { cwd, stdio: [0,1,2] }); | ||
} | ||
|
||
function processAllExamples() { | ||
const files = readdirSync(".", { withFileTypes: true }); | ||
const failures = []; | ||
files.forEach((file) => { | ||
if (file.isDirectory() && !BROKEN_RECIPES.includes(file.name)) { | ||
const cwd = "./" + file.name; | ||
console.log(cwd); | ||
try { | ||
installPackages(cwd); | ||
runE2eTests(cwd); | ||
} catch (ex) { | ||
failures.push(ex); | ||
} | ||
} | ||
}); | ||
if (failures.length > 0) { | ||
throw new Error('E2E Tests Failed'); | ||
} | ||
} | ||
processAllExamples(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const { execSync } = require("child_process"); | ||
const { readdirSync } = require("fs"); | ||
|
||
const BROKEN_RECIPES = [".git", ".github"]; | ||
|
||
function installPackages(cwd) { | ||
console.log("Installing packages for " + cwd); | ||
const files = readdirSync(cwd); | ||
if (files.includes("pnpm-lock.yaml")) { | ||
execSync("pnpm i", { cwd, stdio: [0, 1, 2] }); | ||
} else if (files.includes("yarn.lock")) { | ||
execSync("yarn", { cwd, stdio: [0, 1, 2] }); | ||
} else { | ||
execSync("npm ci --legacy-peer-deps", { cwd, stdio: [0, 1, 2] }); | ||
} | ||
} | ||
function migrateToLatest(cwd) { | ||
console.log(`Migrating ${cwd}...`); | ||
execSync("CI=true npx nx migrate latest", { cwd, stdio: [0, 1, 2] }); | ||
execSync("CI=true npx nx migrate --run-migrations --no-interactive", { | ||
cwd, | ||
stdio: [0, 1, 2], | ||
timeout: 60000, | ||
}); | ||
execSync("rm -rf migrations.json", { cwd, stdio: [0, 1, 2] }); | ||
console.log(`Done migrating ${cwd}.`); | ||
} | ||
|
||
function processAllExamples() { | ||
const files = readdirSync(".", { withFileTypes: true }); | ||
let failedMigrations = []; | ||
files.forEach((file) => { | ||
if (file.isDirectory() && !BROKEN_RECIPES.includes(file.name)) { | ||
const cwd = "./" + file.name; | ||
installPackages(cwd); | ||
try { | ||
migrateToLatest(cwd); | ||
} catch (ex) { | ||
console.log(ex); | ||
console.log("Continuing to next example..."); | ||
failedMigrations.push(cwd); | ||
} | ||
} | ||
}); | ||
if (failedMigrations.length > 0) { | ||
console.log( | ||
"The following migrations failed: " + failedMigrations.join(", ") | ||
); | ||
} | ||
} | ||
processAllExamples(); |