github workflows: add working-directory input parameter
Add optional working-directory input parameter to both go_test.yml and
webui_test.yml workflows with default value of '.', allowing workflows
to be run from different subdirectories when needed.
Changes made:
- go_test.yml: Added working-directory input, updated go.mod path reference,
added working-directory to Go generate and test steps
- webui_test.yml: Added working-directory input, updated package-lock.json path,
updated all webui-related step working directories and artifact path
Both workflows maintain backward compatibility with default '.' value while
enabling flexible directory targeting for workflow reuse.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: sbece0e025c355895k
diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml
index 01403c4..e71e1fc 100644
--- a/.github/workflows/go_test.yml
+++ b/.github/workflows/go_test.yml
@@ -7,6 +7,11 @@
required: false
type: string
default: ""
+ working-directory:
+ description: "Working directory for the workflow"
+ required: false
+ type: string
+ default: "."
push:
branches-ignore:
- "queue-main-*"
@@ -22,7 +27,7 @@
- uses: actions/setup-go@v5
with:
- go-version-file: "go.mod"
+ go-version-file: "${{ inputs.working-directory || '.'}}/go.mod"
cache: true
- name: Cache Go 1.24.4
@@ -35,7 +40,10 @@
${{ runner.os }}-go1.24.4-
- name: Optimize APT
- run: ./.github/scripts/optimize-apt.sh
+ working-directory: ${{ inputs.working-directory || '.'}}
+ run: |
+ pwd
+ ./.github/scripts/optimize-apt.sh
- name: Install tools
run: |
@@ -46,7 +54,7 @@
# Empirically (by logging into runners with tmate), there are versions of Chromium/Chrome in /opt/google/chrome
# and /usr/local/share/chromium/chrome-linux, and /usr/bin/chromium links to the former. Therefore, we
# don't need to apt-get it separately.
-
+
# If you wish to do some interactive debugging, the following is handy. It will print
# an SSH command that you can use to connect to the runner instance.
- name: tmate debugging (disabled)
@@ -60,6 +68,7 @@
sleep 1800
- name: Go generate
+ working-directory: ${{ inputs.working-directory || '.'}}
run: |
go generate ./...
# if go generate created a diff
@@ -70,6 +79,7 @@
fi
- name: Run tests
+ working-directory: ${{ inputs.working-directory || '.'}}
run: |
GOEXPERIMENT=synctest gotestsum --format testname -- ./...
GOEXPERIMENT=synctest gotestsum --format testname -- -race ./...
diff --git a/.github/workflows/webui_test.yml b/.github/workflows/webui_test.yml
index 6a12c9a..490f162 100644
--- a/.github/workflows/webui_test.yml
+++ b/.github/workflows/webui_test.yml
@@ -7,6 +7,11 @@
required: false
type: string
default: ""
+ working-directory:
+ description: "Working directory for the workflow"
+ required: false
+ type: string
+ default: "."
push:
branches-ignore:
- "queue-main-*"
@@ -30,21 +35,24 @@
with:
node-version: "20"
cache: "npm"
- cache-dependency-path: webui/package-lock.json
+ cache-dependency-path: ${{ inputs.working-directory || '.'}}/webui/package-lock.json
- name: Optimize APT
- run: ./.github/scripts/optimize-apt.sh
+ working-directory: ${{ inputs.working-directory || '.'}}
+ run: |
+ pwd
+ ./.github/scripts/optimize-apt.sh
- name: Install dependencies
- working-directory: ./webui
+ working-directory: ${{ inputs.working-directory || '.'}}/webui
run: npm ci
- name: Install Playwright Chromium
- working-directory: ./webui
+ working-directory: ${{ inputs.working-directory || '.'}}/webui
run: npx playwright install chromium --with-deps
- name: Run tests
- working-directory: ./webui
+ working-directory: ${{ inputs.working-directory || '.'}}/webui
run: npm run test
- name: Upload test results
@@ -52,5 +60,5 @@
uses: actions/upload-artifact@v4
with:
name: playwright-report
- path: webui/playwright-report/
+ path: ${{ inputs.working-directory || '.'}}/webui/playwright-report/
retention-days: 7