Skip to content
Merged
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
77 changes: 77 additions & 0 deletions .github/workflows/ci-license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Check license updates

on:
workflow_call:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

env:
TURBO_TELEMETRY_DISABLED: 1

jobs:
license-check:
name: License Check
runs-on: 'ubuntu-latest'
permissions:
pull-requests: write
steps:
- name: 👷 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: 🛠️ Setup workspace
uses: ./.github/actions/setup-workspace
with:
node-version: '20'

- name: ⬇️ Download Build Archive
uses: ./.github/actions/download-archive
with:
name: vscode-webdriverio
path: .
filename: vscode-webdriverio-build.zip

- name: 📃 Generate License file
run: pnpm --filter @vscode-wdio/compiler build -p vscode-webdriverio -l
shell: bash

- name: ✅ Check status
id: check
run: |
if [[ $(git status --short | grep -c -v vscode-webdriverio-build.zip) -ne 0 ]]; then
STATUS=$(git status --verbose); printf "%s" "$STATUS"; git diff | cat
echo "result=1" >> $GITHUB_OUTPUT
else
echo "result=0" >> $GITHUB_OUTPUT
fi
shell: bash

- uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
if: ${{ steps.check.outputs.result > 0 }}
with:
header: license-error
message: >
Thank you for creating PR!🙏

It is likely that the license file needs to be updated due to changes in dependencies.

Please run following commands at project root directory.
```
$ pnpm run build

$ git add packages/vscode-webdriverio/LICENSE.md

$ git commit
```

If you have any questions please reach out to us on our [Discord](https://discord.webdriver.io/)
channel. We are happy to help you out there.

- name: 💥 Exit with error
if: ${{ steps.check.outputs.result > 0 }}
run: exit 1

- uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
if: ${{ steps.check.outputs.result == 0 }}
with:
header: license-error
delete: true
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
pull-requests: write

jobs:
build:
name: Build
Expand All @@ -29,6 +32,11 @@ jobs:
needs: [lint, build]
uses: ./.github/workflows/ci-typecheck.yml

license-check:
name: License Check
needs: [lint, build]
uses: ./.github/workflows/ci-license.yml

unit:
name: Unit
needs: [lint, build]
Expand All @@ -48,21 +56,21 @@ jobs:

smoke-config:
name: Smoke - Update Config
needs: [lint, build, e2e]
needs: [lint, build, unit, license-check, typecheck, e2e]
uses: ./.github/workflows/ci-smoke.yml
with:
scenario: 'config'

smoke-timeout:
name: Smoke - Worker idle timeout
needs: [lint, build, e2e]
needs: [lint, build, unit, license-check, typecheck, e2e]
uses: ./.github/workflows/ci-smoke.yml
with:
scenario: 'timeout'

smoke-env:
name: Smoke - Load .env files
needs: [lint, build, e2e]
needs: [lint, build, unit, license-check, typecheck, e2e]
uses: ./.github/workflows/ci-smoke.yml
with:
scenario: 'env'
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[markdown]": {
"files.trimTrailingWhitespace": false
}
}
2 changes: 2 additions & 0 deletions infra/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"build": "tsx ./src/index.ts"
},
"dependencies": {
"chalk": "^5.4.1",
"esbuild": "^0.25.0",
"fdir": "^6.4.6",
"type-fest": "^4.24.0"
}
}
22 changes: 20 additions & 2 deletions infra/compiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { parseArgs } from 'node:util'

import { context } from 'esbuild'

import { generateLicense } from './license.js'
import { esbuildProblemMatcherPlugin } from './plugins.js'

import type { PackageJson } from 'type-fest'
Expand All @@ -24,6 +25,11 @@ const optionsDef = {
production: {
type: 'boolean',
},
onlyLicense: {
type: 'boolean',
short: 'l',
default: false,
},
} as const

const { values: options } = parseArgs({ args, options: optionsDef })
Expand All @@ -41,6 +47,18 @@ if (!fss.existsSync(pkgPath)) {
const pkg = (await import(url.pathToFileURL(pkgPath).href, { with: { type: 'json' } })).default

const absWorkingDir = path.dirname(pkgPath)
const outdir = path.resolve(absWorkingDir, 'dist')

if (options.onlyLicense) {
const metafile = path.join(outdir, 'meta.json')
if (!fss.existsSync(metafile)) {
throw new Error(`Meta file was not found: ${metafile}\nPlease execute \`pnpm run build\` at root directory.`)
}
const meta = JSON.parse(fss.readFileSync(metafile, { encoding: 'utf-8' }))
generateLicense(rootDir, pkgPath, meta)
console.log('The license file was generated successfully.')
process.exit(0)
}

const exports = (pkg.exports || {}) as PackageJson.ExportConditions

Expand All @@ -60,8 +78,6 @@ if (entryPoints.length < 1) {
throw new Error(`No export module found to build at: ${absWorkingDir}`)
}

const outdir = path.resolve(absWorkingDir, 'dist')

const ctx = await context({
sourceRoot: absWorkingDir,
entryPoints,
Expand Down Expand Up @@ -89,5 +105,7 @@ if (options.watch) {

if (!options.production) {
fss.writeFileSync(path.join(outdir, 'meta.json'), JSON.stringify(result.metafile))

generateLicense(rootDir, pkgPath, result.metafile)
}
}
Loading