Skip to content

Commit

Permalink
Use YQ to generate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Y0sh1dk committed Dec 17, 2023
1 parent ba4da7a commit 8f95d93
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 47 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/autogen-test.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
if: github.event_name == 'pull_request'
with:
commit_message: "[skip ci] Update tests"
file_pattern: ".github/workflows/autogen-test.yaml"
file_pattern: ".github/workflows/test.yaml"
branch: ${{ steps.generate_branch.outputs.branch }}
create_branch: true

Expand All @@ -91,7 +91,7 @@ jobs:
owner: Y0sh1dk
repo: gha-docker-image-exists
github_token: ${{ secrets.GHA_TOKEN }}
workflow_file_name: autogen-test.yaml
workflow_file_name: test.yaml
ref: ${{ steps.generate_branch.outputs.branch }}
wait_workflow: true
comment_downstream_url: ${{ github.event.pull_request.comments_url }}
Expand Down
File renamed without changes.
23 changes: 19 additions & 4 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ vars:
GO_MOD_CACHE_VOLUME: go-module-cache
GIT_REPO_NAME:
sh: basename $(git rev-parse --show-toplevel)
GIT_REPO_OWNER: Y0sh1dk
GIT_REPO_FULL: "{{ .GIT_REPO_OWNER }}/{{ .GIT_REPO_NAME }}"

tasks:
create-go-mod-cache-volume:
Expand Down Expand Up @@ -46,6 +48,19 @@ tasks:
hairyhenderson/gomplate:stable \
{{ .COMMAND }}
_yq-docker: &yq-docker
internal: true
cmds:
- |
docker run \
--rm \
-e WORKFLOW_NAME={{ .WORKFLOW_NAME }} \
-e ACTION_VERSION={{ .ACTION_VERSION }} \
-v $(pwd):/app \
-w /app \
mikefarah/yq:latest \
{{ .COMMAND }}
build:
<<: *go-docker
internal: false
Expand All @@ -62,15 +77,15 @@ tasks:
COMMAND: go build -ldflags="-w -s" -o bin/{{ .GIT_REPO_NAME }}-{{ .GOOS }}-{{ .GOARCH }} *.go {{ .CLI_ARGS }}

gen-tests:
<<: *gomplate-docker
<<: *yq-docker
internal: false
desc: Generate test workflows
requires:
vars: [ACTION_VERSION]
vars:
WORKFLOW_NAME: "{{ .GIT_REPO_NAME }}"
ACTION_VERSION: "{{ .ACTION_VERSION }}"
COMMAND: -f .github/workflows/test.yaml.tmpl --left-delim "[[[" --right-delim "]]]" > .github/workflows/autogen-test.yaml
ACTION_VERSION: "{{ .GIT_REPO_FULL}}@{{ .ACTION_VERSION }}"
COMMAND: |
-i '.jobs.[].steps[] |= (select(has("uses") and .uses == "{{ .GIT_REPO_FULL }}@*") | .uses = env(ACTION_VERSION))' .github/workflows/test.yaml
build-all:
desc: Build the application for all platforms
Expand Down

0 comments on commit 8f95d93

Please sign in to comment.