-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: move input setup to inline bash (#145)
Because of path shenanigans when running the trunk-action in a container, the input-setup action wasn't getting found by node. To avoid this, I've rewritten the logic in bash. This PR also fixes TRUNK-7633 and adds tests for running the action in a container, so we don't get blindsided by something like this again. Workflow dispatch code path was tested manually with the services cli tool [here](https://github.com/trunk-io/.trunk-internal/actions/runs/5350157016/jobs/9702379590). ----- Some context on the things I tried prior to this: - I tried using `$GITHUB_ACTION_PATH` instead of `${{ github.action_path}}` to find the action, as the environment variable is set correctly, but the context variable is not. However, using the env var, github fails to find the action at all. Using the context variable, github finds the `action.yml` and `mask.js` files, but passes an incorrect path into node to run. - I considered calling the subaction directly with `uses: trunk-io/trunk-action/input-setup@v1` - however, this would potentially introduce a version mismatch between the version of the action being run and the version of the subaction being wrong - I considered simply calling `node mask.js` inline in the composite action, but didn't want to add a setup node action that would potentially conflict with another node install - I tried to use templating in the main filename javascript action to pass in the correct path - while you can use templating in that field, you cannot access the `env` or `input` contexts, making it impossible to set the field correctly.
- Loading branch information
Showing
7 changed files
with
218 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: docker_repo_tests | ||
on: [workflow_dispatch, workflow_call] | ||
|
||
jobs: | ||
repo_tests: | ||
name: ${{ matrix.repo }} ${{ matrix.description }} | ||
runs-on: ubuntu-latest | ||
# This is a docker image that mimics the github runner image | ||
# https://github.com/catthehacker/docker_images/pkgs/container/ubuntu | ||
container: catthehacker/ubuntu:runner-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
# Items in this list satisfy a few criteria: | ||
# | ||
# * test has to be useful/interesting and add value atop the monorepo tests for | ||
# trunk init | ||
# | ||
# * the repo has to exercise some functionality specific to action.yaml (e.g. our | ||
# custom Node functionality for npm/yarn/pnpm) | ||
# | ||
# * the repo and its dependency closure should be fast to set up, since we trigger | ||
# this workflow on PRs | ||
# | ||
- repo: highlightjs/highlight.js | ||
ref: 4f9cd3bffb6bc55c9e2c4252c7b733a219880151 | ||
description: (uses npm) | ||
post-init: | | ||
# terrascan scans dockerfile.js (a JS file for parsing dockerfiles) as a dockerfile itself | ||
echo "src/languages/dockerfile.js" >> .gitignore | ||
cp local-action/repo_tests/highlightjs.yaml .trunk/user.yaml | ||
- repo: pallets/flask | ||
ref: 4bcd4be6b7d69521115ef695a379361732bcaea6 | ||
post-init: | | ||
# bandit is outputting a progress bar (TODO: TRUNK-7656) | ||
${TRUNK_PATH} check disable bandit | ||
# prettier chokes on this malformed html file | ||
echo "examples/celery/src/task_app/templates/index.html" >> .gitignore | ||
cp local-action/repo_tests/flask.yaml .trunk/user.yaml | ||
- repo: postcss/postcss | ||
ref: aa9e03ea4708909631eba70500c8c0cc0708bb4e | ||
description: (uses pnpm) | ||
post-init: | | ||
${TRUNK_PATH} check enable eslint | ||
- repo: postcss/postcss | ||
ref: aa9e03ea4708909631eba70500c8c0cc0708bb4e | ||
description: (compat test for cli 1.0.0) | ||
post-init: | | ||
${TRUNK_PATH} check enable eslint | ||
- repo: sass/sass | ||
ref: 225e176115211387e014d97ae0076d94de3152a1 | ||
description: (uses npm) | ||
|
||
- repo: terraform-linters/tflint | ||
ref: 9c34a740319e2410094ca2754e5eca860f2d13f5 | ||
post-init: | | ||
# golangci-lint needs us to init with a newer go runtime | ||
${TRUNK_PATH} check disable golangci-lint | ||
# tfsec and terrascan scan these malformed test files and error | ||
echo "integrationtest/" >> .gitignore | ||
echo "terraform/test-fixtures" >> .gitignore | ||
- repo: trunk-io/plugins | ||
ref: main | ||
|
||
- repo: z-shell/wiki | ||
ref: d6d8b5da28c170b3b226705795412497f7059681 | ||
description: (has trunk.yaml) | ||
post-init: | | ||
# stylelint is exiting with error code -11 | ||
${TRUNK_PATH} check disable stylelint | ||
steps: | ||
- name: Checkout ${{ matrix.repo }} | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ matrix.repo }} | ||
ref: ${{ matrix.ref }} | ||
|
||
- name: Checkout ${{ github.repository }} | ||
uses: actions/checkout@v3 | ||
with: | ||
path: local-action | ||
|
||
- name: Run trunk-action in ${{ matrix.repo }} | ||
id: trunk | ||
uses: ./local-action/ | ||
with: | ||
cache: true | ||
check-mode: all | ||
post-init: ${{ matrix.post-init }} | ||
arguments: --output-file=/tmp/landing-state.json | ||
cache-key: repo_tests/${{ matrix.repo }} | ||
setup-deps: true | ||
env: | ||
TRUNK_CLI_VERSION: | ||
${{ matrix.description == '(compat test for cli 1.0.0)' && '1.0.0' || '' }} | ||
continue-on-error: true | ||
|
||
- name: Check for task failures | ||
shell: bash | ||
run: | | ||
python3 local-action/repo_tests/check_for_task_failures.py \ | ||
'${{ github.env }}' \ | ||
'${{ matrix.repo }}' \ | ||
'${{ matrix.description }}' | ||
- name: Upload landing state | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.landing_state_artifact_name }} landing state | ||
path: .trunk/landing-state.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.