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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
/scripts/doctor.sh @sabiut
/.github/workflows/test-artifacts.yml @sabiut
/.github/workflows/test-flags.yml @sabiut
/.github/workflows/tests.yml @sabiut

# Shared review — either owner can approve.
# TROUBLESHOOTING is mostly the --doctor user-facing guide; lint
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: BATS Tests
run-name: |
BATS: ${{
github.event_name == 'pull_request' && format('PR #{0} by @{1} - {2}', github.event.pull_request.number, github.actor, github.event.pull_request.title) ||
github.event_name == 'push' && github.event.head_commit && format('Push by @{0} - {1}', github.actor, github.event.head_commit.message) ||
format('{0} triggered by @{1}', github.event_name, github.actor)
}}

on:
push:
branches:
- main
paths:
- "tests/**"
- "scripts/**"
- ".github/workflows/tests.yml"
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: bats-${{ github.ref }}
cancel-in-progress: true

jobs:
bats:
name: BATS unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install BATS and Node.js
run: |
sudo apt-get update
sudo apt-get install -y bats nodejs

- name: Run BATS test suite
# Cowork tests load scripts/cowork-vm-service.js via `node` —
# the `nodejs` install above is what they need.
run: bats --print-output-on-failure tests/*.bats
6 changes: 6 additions & 0 deletions tests/cowork-bwrap-config.bats
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ function assertDeepEqual(actual, expected, msg) {
setup() {
TEST_TMP=$(mktemp -d)
export TEST_TMP

# The doctor checks resolve config via ${XDG_CONFIG_HOME:-$HOME/.config}.
# Sandboxing HOME alone is insufficient because GitHub Actions runners
# (and many user environments) export XDG_CONFIG_HOME ambient, which
# overrides the per-test HOME and makes the function read the wrong dir.
unset XDG_CONFIG_HOME
}

teardown() {
Expand Down