Skip to content

Commit

Permalink
CI build changed plugins (#1323)
Browse files Browse the repository at this point in the history
* Fix WritableDeviceState

* Fix tsconfig error

* Fix test

* Create build-plugins-changed.yml

* Update build-sdk.yml

* Update build-plugins-changed.yml
  • Loading branch information
longzheng authored Feb 19, 2024
1 parent 064da32 commit eec6291
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-plugins-changed.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions plugins/snapshot/test/test.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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();
3 changes: 2 additions & 1 deletion plugins/snapshot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"sourceMap": true
},
"include": [
"src/**/*"
"src/**/*",
"test/**/*",
]
}

0 comments on commit eec6291

Please sign in to comment.