Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: CI workflows for automatic tests and publication #26

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build & Test
on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read
checks: write
statuses: write

jobs:
setup:
name: Setup
runs-on: ubuntu-24.04
steps:
- name: Create the commit status check
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
STATUS_REPO: ${{ github.repository }}
STATUS_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
STATUS_STATE: pending
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -x
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${STATUS_REPO}/statuses/${STATUS_SHA}" \
-f "state=${STATUS_STATE}" \
-f "target_url=${STATUS_URL}" \
-f "description=PR Check Workflow" \
-f "context=IMG.LY"
test:
name: Test Node ${{ matrix.node-version }}
needs: [setup]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
node-version:
- '18.x'
- '20.x'
- '22.x'
env:
CI_NODE_VERSION: ${{ matrix.node-version }}
CI_IS_PR: ${{ github.event_name == 'pull_request' }}
# In PRs, rebuild the changed packages, their dependents and dependencies only, unless the ci:build-all label is applied.
CI_PNPM_FILTER: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci:build-all')) && '...[origin/main]...' || '*' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ env.CI_NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.CI_NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
pnpm recursive install --filter "$CI_PNPM_FILTER" --frozen-lockfile
- name: Build
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" build
- name: Run checks
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" check:all
- name: Test
shell: bash
run: pnpm recursive run --filter "$CI_PNPM_FILTER" test
- name: Package
if: success() || failure()
shell: bash
run: |
mkdir -p _ci_packs
pnpm recursive --filter "$CI_PNPM_FILTER" exec pnpm pack "--pack-destination=$PWD/_ci_packs"
- name: Upload packages
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-npm-packages-node${{ env.CI_NODE_VERSION }}.zip
path: '_ci_packs/*.tgz'
if-no-files-found: ignore
overwrite: true

summary:
name: Summary test status
needs: [test]
if: always()
runs-on: ubuntu-24.04
steps:
- name: Update the commit status check
if: always()
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
STATUS_REPO: ${{ github.repository }}
STATUS_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
STATUS_STATE: ${{ needs.test.result == 'success' && 'success' || 'failure' }}
STATUS_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -x
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${STATUS_REPO}/statuses/${STATUS_SHA}" \
-f "state=${STATUS_STATE}" \
-f "target_url=${STATUS_URL}" \
-f "description=PR Check Workflow" \
-f "context=IMG.LY"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ packages/*/dist
examples/*/dist
.env.local
.nvmrc
*.tgz

.DS_Store
yarn-error.log

.turbo
_ci_*
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; Allow transitive dependency type access
shamefully-hoist = true
strict-peer-dependencies = true
verify-deps-before-run = error
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Plugins enhance the capabilities of [CreativeEditor SDK (CE.SDK)](https://img.ly
- Customization: Tailor the functionality of CE.SDK to meet specific needs.
- Compatibility: Designed to work seamlessly with the latest version of CE.SDK.

> [!WARNING]
> The plugin APIs are still in development and thus marked as unstable in CE.SDK. While it is perfectly safe to use the plugins for the specified CE.SDK versions, the APIs might change in the future. Please be aware, if you write your own plugin based on the code in this repository.

# Currently Available Plugins

For more information about the particular plugins, please visit the according packages in this repository.

- [Background Removal](packages/plugin-background-removal-web/)
- [Cutouts](packages/plugin-cutout-library-web/)
- [Remote Asset Source](packages/plugin-remote-asset-source-web/)
- [Vectorizer](packages/plugin-vectorizer-web/)
3 changes: 3 additions & 0 deletions esbuild/config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import dtsPlugin from './plugin-dts.mjs';
import reporterPlugin from './plugin-reporter.mjs';

/** @import { BuildOptions } from 'esbuild' */

export default ({ isDevelopment, pluginVersion, pluginName, external }) => {
/** @type { BuildOptions } */
const config = {
entryPoints: ['src/index.ts'],
define: {
Expand Down
7 changes: 4 additions & 3 deletions esbuild/plugin-dts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const dtsPlugin = {
dtsStdio = undefined;
dtsResolved = false;
log('Generating types...');
exec('yarn types:create', (error, stdio) => {
exec('pnpm run types:create', (error, stdio) => {
if (error) {
dtsError = error;
dtsStdio = stdio;
Expand All @@ -22,17 +22,18 @@ const dtsPlugin = {
});
});
build.onEnd(async () => {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const interval = setInterval(() => {
if (dtsResolved) {
clearInterval(interval);
if (dtsError) {
log(chalk.red('Type Error'));
console.log(dtsStdio);
reject(new Error('Type Error'));
} else {
log(`Type Generation ${chalk.green('succeeded')}`);
resolve();
}
resolve();
}
}, 200);
});
Expand Down
47 changes: 28 additions & 19 deletions examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,40 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "tsc && vite build --force",
"clean": "npx rimraf dist",
"purge": "npx rimraf node_modules",
"build": "tsc && vite build",
"clean": "pnpm exec rimraf dist",
"purge": "pnpm exec rimraf node_modules",
"dev": "vite --clearScreen=false --force",
"check:types": "tsc --noEmit"
},
"dependencies": {
"@cesdk/cesdk-js": "1.41.0",
"@imgly/plugin-background-removal-web": "*",
"@imgly/plugin-cutout-library-web": "*",
"@imgly/plugin-remote-asset-source-web": "*",
"@cesdk/cesdk-js": "^1.41.0",
"@imgly/plugin-background-removal-web": "workspace:*",
"@imgly/plugin-cutout-library-web": "workspace:*",
"@imgly/plugin-remote-asset-source-web": "workspace:*",
"@imgly/plugin-qr-code-web": "workspace:*",
"@imgly/plugin-vectorizer-web": "workspace:*",
"onnxruntime-web": "1.21.0-dev.20250114-228dd16893",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"dependenciesMeta": {
"@imgly/plugin-background-removal-web": { "injected": true },
"@imgly/plugin-cutout-library-web": { "injected": true },
"@imgly/plugin-remote-asset-source-web": { "injected": true },
"@imgly/plugin-qr-code-web": { "injected": true },
"@imgly/plugin-vectorizer-web": { "injected": true }
},
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.2.2",
"vite": "^5.0.8"
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.3.2",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"typescript": "^5.6.3",
"vite": "^5.4.8"
}
}
Loading
Loading