From eec6291d9e69ee2354cb463d6cdb235b3197c6de Mon Sep 17 00:00:00 2001 From: Long Zheng Date: Mon, 19 Feb 2024 18:12:39 +1100 Subject: [PATCH] CI build changed plugins (#1323) * Fix WritableDeviceState * Fix tsconfig error * Fix test * Create build-plugins-changed.yml * Update build-sdk.yml * Update build-plugins-changed.yml --- .github/workflows/build-plugins-changed.yml | 40 +++++++++++++++++++++ .github/workflows/build-sdk.yml | 2 +- plugins/snapshot/test/test.ts | 26 -------------- plugins/snapshot/tsconfig.json | 3 +- 4 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/build-plugins-changed.yml diff --git a/.github/workflows/build-plugins-changed.yml b/.github/workflows/build-plugins-changed.yml new file mode 100644 index 000000000..046127edc --- /dev/null +++ b/.github/workflows/build-plugins-changed.yml @@ -0,0 +1,40 @@ +name: Build changed plugins + +on: + push: + branches: ["main"] + paths: ["plugins/**"] + pull_request: + paths: ["plugins/**"] + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Set up base packages + run: ./npm-install.sh + + - name: Build changed plugins + run: | + # Get the list of changed directories in /plugins + changed_dirs=$(git diff --name-only HEAD^ HEAD ./plugins | awk -F/ '{print $2}' | uniq) + + # Loop through each changed directory + for dir in $changed_dirs; do + pushd "./plugins/$dir" + echo "plugins/$dir > npm install" + npm install + echo "plugins/$dir > npm run build" + npm run build + popd + done diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml index 871797135..b14794325 100644 --- a/.github/workflows/build-sdk.yml +++ b/.github/workflows/build-sdk.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 18 - run: npm ci diff --git a/plugins/snapshot/test/test.ts b/plugins/snapshot/test/test.ts index 86861c9dd..7a77a2bb2 100644 --- a/plugins/snapshot/test/test.ts +++ b/plugins/snapshot/test/test.ts @@ -1,6 +1,5 @@ import { writeFileSync } from "fs"; import { ffmpegFilterImage } from "../src/ffmpeg-image-filter"; -import { sharpFilterImage } from "../src/sharp-image-filter"; import path from 'path'; async function main1() { @@ -27,29 +26,4 @@ async function main1() { console.log('test1 done'); } -async function main2() { - const ret = await sharpFilterImage('/Users/koush/Downloads/151-1678381127261.jpg', - { - blur: true, - // crop: { - // // fractional: true, - // left: 100, - // top: 100, - // width: 1000, - // height: 500, - // }, - brightness: -.2, - text: { - fontFile: path.join(__dirname, '../fs/Lato-Bold.ttf'), - text: 'Hello World', - } - // } - // { "crop": { "left": 0.216796875, "top": 0.2552083333333333, "width": 0.318359375, "height": 0.17907714843749994, "fractional": true } - } - ); - writeFileSync('test2.jpg', ret); - console.log('test2 done'); -} - main1(); -main2(); diff --git a/plugins/snapshot/tsconfig.json b/plugins/snapshot/tsconfig.json index a976b26c4..f38f8df74 100644 --- a/plugins/snapshot/tsconfig.json +++ b/plugins/snapshot/tsconfig.json @@ -8,6 +8,7 @@ "sourceMap": true }, "include": [ - "src/**/*" + "src/**/*", + "test/**/*", ] } \ No newline at end of file