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
23 changes: 15 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,110 +4,117 @@
workflow_dispatch:
push:
branches:
- '*'
- 'staging'
- 'main'
tags:
- "v*"
pull_request:
branches:
- '*'
schedule: # This run is just to keep the self-hosted runner active. They get deleted after 14 days of inactivity.
- cron: '0 8 * * 1' # Run weekly on Mondays at 9AM CET (8AM UTC)

jobs:
build-test-vscode:

runs-on: ubuntu-latest
# We need a faster runner with a Yocto cache in order for the tests to complete in time
runs-on: self-hosted

defaults:
run:
shell: bash

env:
DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1001/bus
SHELL: /usr/bin/bash
node-version: 20

steps:
- name: Enable unprivileged user namespaces
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns

- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: |
package-lock.json
server/package-lock.json
client/package-lock.json

- name: Install Node.js dependencies
run: npm install

# Inspired by https://stackoverflow.com/a/72981982
- name: Configure Git autor for Yocto do_patch
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

- name: Install apt dependencies
run: sudo apt install chrpath diffstat

- name: Cache fetch
id: cache-fetch
uses: actions/cache@v4
with:
path: |
server/resources/docs
server/resources/spdx-licenses.json
resources/poky
key: cache-${{ hashFiles('scripts/fetch-poky.sh', 'scripts/fetch-docs.sh', 'scripts/fetch-spdx-licenses.sh') }}

- name: Fetch
if: steps.cache-fetch.outputs.cache-hit != 'true'
run: npm run fetch:poky && npm run fetch:docs && npm run fetch:spdx-licenses

- name: Cache build Wasm files
id: cache-wasm
uses: actions/cache@v4
with:
path: |
server/tree-sitter-bash.wasm
server/tree-sitter-bitbake.wasm
key: cache-${{ hashFiles('server/tree-sitter-bash.info', 'server/tree-sitter-bitbake.info') }}

- name: Fetch Wasm files
if: steps.cache-wasm.outputs.cache-hit != 'true'
run: npm run fetch:wasm

- name: Run Linter
run: npm run lint

- name: Build Project
run: npm run compile

- name: Cache VSCode installation
uses: actions/cache@v4
with:
path: |
.vscode-test/vscode-*
.vscode-test/extensions
key: cache-${{ hashFiles('integration-tests/src/runTest.ts') }}

- name: Test Project
run: npm run test
env:
# NFS Yocto cache directories on the self-hosted runner
DL_DIR: /var/cache/yocto/yocto-dldir
SSTATE_DIR: /var/cache/yocto/yocto-sstate
BB_ENV_PASSTHROUGH_ADDITIONS: "DL_DIR SSTATE_DIR"

- name: Build the VSIX
run: npm run package

- name: Archive VSIX
uses: actions/upload-artifact@v4
with:
name: vscode-bitbake
path: ./yocto-bitbake*.vsix

- name: Cleanup
if: success()
run: npm run clean

# Inspired by https://github.com/microsoft/vscode-platform-specific-sample/blob/a0192a21122dfa5c90934b006f027cdf4e4d892d/.github/workflows/ci.yml#L64C11-L64C11 MIT License
publish-vsce:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
environment: VSCE
needs: build-test-vscode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import * as fs from 'fs'
import { BitbakeDriver } from '../../../driver/BitbakeDriver'
import { type BitbakeTaskDefinition } from '../../../ui/BitbakeTaskProvider'
import { BITBAKE_TIMEOUT } from '../../../utils/ProcessUtils'

describe('BitbakeDriver Tests', () => {
it('should protect from shell injections', (done) => {
Expand All @@ -22,7 +23,7 @@ describe('BitbakeDriver Tests', () => {
done()
})
})
})
}, BITBAKE_TIMEOUT)

it('should source the environment script', (done) => {
const fakeEnvScriptPath = '/tmp/bitbake-vscode-test/envsetup.sh'
Expand Down
11 changes: 9 additions & 2 deletions client/src/__tests__/unit-tests/driver/scanner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import path from 'path'
import fs from 'fs'
import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
import { BitbakeDriver } from '../../../driver/BitbakeDriver'
import { BITBAKE_TIMEOUT } from '../../../utils/ProcessUtils'
import { BITBAKE_BUILD_TIMEOUT, BITBAKE_TIMEOUT } from '../../../utils/ProcessUtils'
import { mockVscodeEvents } from '../../utils/vscodeMock'
import { importRecipe, removeRecipe, integrationBitbakeFolder } from '../../utils/bitbake'
import { logger } from '../../../lib/src/utils/OutputLogger'
Expand Down Expand Up @@ -54,7 +54,14 @@ describe('BitBakeProjectScanner', () => {
}, (error) => {
throw error
})
}, BITBAKE_TIMEOUT)
// Running devtool modify needs to build uninative, quilt-native, and a few recipes
// Since the age of AI, fetching anything now takes ages, so we increase the timeout
// Note that such a timeout is only possible on Github self-hosted runners or local machines
// Public Github runners have a max timeout of 1 hour per job
// The workspace is kept for the remaining tests, so we don't need to do it again
// Also, our self-hosted runner have a Yocto sstate cache, so it's only
// rebuilt when changing the openembedded version
}, BITBAKE_BUILD_TIMEOUT)

afterAll((done) => {
bitBakeProjectScanner.bitbakeDriver.spawnBitbakeProcess('devtool reset busybox').then((child) => {
Expand Down
3 changes: 2 additions & 1 deletion client/src/utils/ProcessUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ function importFromVSCode (id: string): NodeRequire {
// The conversion allows the linter to understand the type of the imported module
export const pty = importFromVSCode('node-pty') as unknown as typeof nodepty

export const BITBAKE_TIMEOUT = 600000 // 10 minutes
export const BITBAKE_TIMEOUT = 300000 // 3 minutes
export const BITBAKE_BUILD_TIMEOUT = 600000 // 10 minutes
export const BITBAKE_EXIT_TIMEOUT = 30000

export type KillProcessFunction = (child: nodepty.IPty) => Promise<void>
Expand Down
Loading