From 3d3bc93b12db9c37b3be35d043102aaa15fa8bd1 Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 17 May 2024 13:54:03 +0800 Subject: [PATCH] add scripts --- .gitignore | 1 + README.md | 14 +++++++++----- clone.js | 18 ++++++++++++++++++ test.js | 18 ++++++++++++++++++ update.js | 18 ++++++++++++++++++ 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100755 clone.js create mode 100755 test.js create mode 100755 update.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc2bbd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/repos diff --git a/README.md b/README.md index 4085e99..ceeb32e 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,24 @@ This repository is used to run integration tests for oxlint ecosystem projects -## via github workflow - -### scheduled +## Scheduled github workflow Workflows are scheduled to run automatically every day -### manually +## Manual github workflow * open [workflow](https://github.com/oxc-project/oxlint-ecosystem-ci/actions/workflows/ecosystem-ci.yml) * click 'Run workflow' button on top right of the list * select suite to run in dropdown * start workflow -## how to add a new integration test +## Local + +- `./clone.js` - clones all the repositories +- `./update.js` - updates (git pull) all the repositories +- `./run.js PATH_TO_OXLINT_BINARY` - run oxlint + +## Add a new integration test * Add your repository to the test-ecosystem matrix [ecosystem-ci.yml](https://github.com/oxc-project/oxlint-ecosystem-ci/blob/main/.github/workflows/ecosystem-ci.yml) * Due to maintenance burden, a [sponsorship](https://github.com/sponsors/Boshen) will have a more likely hood of having the PR accepted. diff --git a/clone.js b/clone.js new file mode 100755 index 0000000..f7ef24a --- /dev/null +++ b/clone.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +const exec = require("child_process").exec; + +const matrix = require("./matrix.json"); + +for (const item of matrix) { + const command = `git clone --depth=1 -b ${item.ref} git@github.com:${item.repository}.git repos/${item.path}`; + + console.log(`Running ${command}`); + exec(command, function (err) { + if (err) { + console.error(err); + return; + } + console.log(`Cloned ${item.repository}`); + }); +} diff --git a/test.js b/test.js new file mode 100755 index 0000000..d219cdc --- /dev/null +++ b/test.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +const execSync = require("child_process").execSync; + +const matrix = require("./matrix.json"); + +const binary = process.argv[2]; + +if (!binary) { + console.error("USAGE: ./test.js PATH_TO_OXLINT_BINARY"); + return; +} + +for (const item of matrix) { + const oxlint = item.command.replace(/^.\/oxlint/, binary); + const command = `cd repos/${item.path} && ${oxlint}`; + execSync(command, { stdio: "inherit" }); +} diff --git a/update.js b/update.js new file mode 100755 index 0000000..55976d5 --- /dev/null +++ b/update.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +const exec = require("child_process").exec; + +const matrix = require("./matrix.json"); + +for (const item of matrix) { + const command = `cd repos/${item.path} && git pull`; + + console.log(`Running ${command}`); + exec(command, function (err) { + if (err) { + console.error(err); + return; + } + console.log(`Updated ${item.repository}`); + }); +}