Skip to content

Commit

Permalink
Merge pull request #13 from d3adb5/feat/install-helm-using-azure-action
Browse files Browse the repository at this point in the history
feat: switch to azure/setup-helm for helm install
  • Loading branch information
d3adb5 authored May 6, 2023
2 parents 84a6948 + cf4429f commit f24f3e9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:

- name: Run composite action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Check that Helm is installed
run: command -v helm >/dev/null 2>/dev/null
Expand Down Expand Up @@ -45,6 +47,8 @@ jobs:
- name: Run composite action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Check that tests were run on all charts
run: |
Expand All @@ -71,6 +75,7 @@ jobs:
- name: Run composite action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
charts: example-chart-2

- name: Check that tests were run on only specified chart
Expand All @@ -90,10 +95,13 @@ jobs:

- name: Run composite action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Try running composite action in force install mode
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
install-mode: force

test-action-if-not-present:
Expand All @@ -107,10 +115,13 @@ jobs:

- name: Run composite action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Try running composite action in if-not-present mode
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
install-mode: if-not-present

test-action-simple-install:
Expand All @@ -124,9 +135,13 @@ jobs:

- name: Run composite action
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Try running composite action in simple install mode
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
id: secondinstall

Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# Helm Unit Tests Action
# Run Helm chart unit tests

Composite action that installs the latest version of Helm through [helm's
install script][helm-install], the latest version of the
Composite action that installs the desired version of Helm through
[azure/setup-helm][setup-helm], the latest version of the
[helm-unittest][helm-unittest] plugin, and then executes chart unit tests for
the specified charts or, if none are specified, for every chart found in the
repository.

[helm-install]: https://github.com/helm/helm/blob/main/scripts/get-helm-3
[setup-helm]: https://github.com/azure/setup-helm
[helm-unittest]: https://github.com/helm-unittest/helm-unittest

## Options

| Input | Description | Required | Default |
|:-------------|:----------------------------------------------------------------------------------------------|:---------|:----------|
| flags | Which flags to pass to helm-unittest when running unit tests. | No | `--color` |
| charts | Paths to the charts to be tested, separated by spaces. If empty, all charts found are tested. | No | `""` |
| install-mode | One of `"force"`, `"if-not-present"`, or `""`. More information below. | No | `""` |
| Input | Description | Required | Default |
|:---------------|:----------------------------------------------------------------------------------------------|:---------|:----------|
| `flags` | Which flags to pass to helm-unittest when running unit tests. | No | `--color` |
| `charts` | Paths to the charts to be tested, separated by spaces. If empty, all charts found are tested. | No | `""` |
| `install-mode` | One of `"force"`, `"if-not-present"`, or `""`. More information below. | No | `""` |
| `helm-version` | Which version of Helm to install. Passed to [azure/setup-helm][setup-helm]. | Yes | `latest` |
| `github-token` | GitHub token for the workflow. Passed to [azure/setup-helm][setup-helm]. Not always needed! | No | `""` |

The `github-token` input is necessary only when installing the latest version
of Helm, to overcome GitHub API rate limits. If not given, refer to the
[azure/setup-helm][setup-helm] README for more information.

### Installation mode

Expand Down Expand Up @@ -45,6 +51,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: d3adb5/helm-unittest-action@v2
with:
helm-version: v3.8.0
github-token: ${{ secrets.GITHUB_TOKEN }}
```
Note that after the action itself, Helm is installed, so you can run additional
Expand Down
17 changes: 13 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ branding:
color: green

inputs:
helm-version:
description: "Which version of Helm to install"
required: true
default: "latest"

github-token:
description: "GitHub token, necessary to overcome API rate limits"
required: false

flags:
description: "Flags to pass to helm unittest"
required: false
Expand All @@ -27,10 +36,10 @@ runs:
using: "composite"
steps:
- name: Install Helm
run: |
installScript=https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
curl "$installScript" 2>/dev/null | bash >/dev/null
shell: bash
uses: azure/setup-helm@v3
with:
version: ${{ inputs.helm-version }}
token: ${{ inputs.github-token }}

- name: Uninstall helm-unittest if present
if: inputs.install-mode == 'force'
Expand Down

0 comments on commit f24f3e9

Please sign in to comment.