Skip to content

Commit

Permalink
feat: add argo-lint and install-argo-cli action (#171)
Browse files Browse the repository at this point in the history
- Split installation of argo-cli into separate `install-argo-cli` action
- Update `trigger-argo-workflow` action using above
- Introduce new `argo-lint` action

---------

Co-authored-by: Iain Lane <[email protected]>
  • Loading branch information
Duologic and iainlane authored Jul 11, 2024
1 parent a9d055f commit d848da2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 44 deletions.
34 changes: 34 additions & 0 deletions actions/argo-lint/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint Argo Workflow files
description: Lint Argo workflow files

inputs:
path:
description: |
Path to files for linting.
required: true

runs:
using: composite

steps:
- name: Checkout
env:
# In a composite action, these two need to be indirected via the
# environment, as per the GitHub actions documentation:
# https://docs.github.com/en/actions/learn-github-actions/contexts
action_repo: ${{ github.action_repository }}
action_ref: ${{ github.action_ref }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: ${{ env.action_repo }}
ref: ${{ env.action_ref }}
path: _shared-workflows-argo-lint

- name: Install argo-cli
uses: ./_shared-workflows-argo-lint/actions/install-argo-cli

- name: Run
env:
WORKFLOW_PATH: ${{ inputs.path }}
shell: bash
run: argo lint --offline "${WORKFLOW_PATH}"
50 changes: 50 additions & 0 deletions actions/install-argo-cli/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Install Argo cli
description: Install Argo cli

inputs:
version:
description: |
Version of the Argo CLI to install.
default: 3.5.1

runs:
using: composite

steps:
- name: Restore cache
id: restore
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ${{ github.workspace }}/bin
key: argo-linux-amd64-${{ inputs.version }}

- name: Fetch Github Release Asset
id: fetch_asset
if: steps.restore.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # 1.1.1
with:
repo: "argoproj/argo-workflows"
version: "tags/v${{ inputs.version }}"
file: "argo-linux-amd64.gz"
target: ${{ github.workspace }}/bin/argo.gz

- name: gunzip
id: gunzip
if: steps.fetch_asset.outcome == 'success'
shell: sh
run: |
gunzip ${{ github.workspace }}/bin/argo.gz
chmod +x ${{ github.workspace }}/bin/argo
- name: Save to cache
id: save
if: steps.gunzip.outcome == 'success'
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ${{ github.workspace }}/bin
key: ${{ steps.restore.outputs.cache-primary-key }}

- name: Add binary to path
shell: sh
run: |
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
46 changes: 2 additions & 44 deletions actions/trigger-argo-workflow/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ runs:
using: composite

steps:
- name: Set argo version
id: argo-version
shell: sh
run: |
ARGO_VERSION=3.5.1
echo "version=${ARGO_VERSION}" >> ${GITHUB_OUTPUT}
- name: Checkout
env:
# In a composite action, these two need to be indirected via the
Expand All @@ -60,43 +53,8 @@ runs:
ref: ${{ env.action_ref }}
path: _shared-workflows-trigger-argo-workflow

- name: Restore cache
id: restore
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ${{ github.workspace }}/bin
key: argo-linux-amd64-${{ steps.argo-version.outputs.version }}

- name: Fetch Github Release Asset
id: fetch_asset
if: steps.restore.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # 1.1.1
with:
repo: "argoproj/argo-workflows"
version: "tags/v${{ steps.argo-version.outputs.version }}"
file: "argo-linux-amd64.gz"
target: ${{ github.workspace }}/bin/argo.gz

- name: gunzip
id: gunzip
if: steps.fetch_asset.outcome == 'success'
shell: sh
run: |
gunzip ${{ github.workspace }}/bin/argo.gz
chmod +x ${{ github.workspace }}/bin/argo
- name: Save to cache
id: save
if: steps.gunzip.outcome == 'success'
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ${{ github.workspace }}/bin
key: ${{ steps.restore.outputs.cache-primary-key }}

- name: Add binary to path
shell: sh
run: |
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
- name: Install argo-cli
uses: ./_shared-workflows-trigger-argo-workflow/actions/install-argo-cli

- name: Setup go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
Expand Down

0 comments on commit d848da2

Please sign in to comment.