Skip to content

Commit

Permalink
Merge pull request #599 from rstudio/kegs-helm-unittests
Browse files Browse the repository at this point in the history
Add helm unittesting scaffolds
  • Loading branch information
dbkegley authored Oct 31, 2024
2 parents 884427b + 50e101c commit da072f6
Show file tree
Hide file tree
Showing 34 changed files with 331 additions and 40 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/chart-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,56 @@ jobs:
if: steps.ct-lint.outcome == 'failure' || steps.ct-lint-all.outcome == 'failure'
run: exit 1

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v4.2.0
with:
version: v3.6.3

- name: Install helm unittest plugin
run: helm plugin install --version v0.6.3 https://github.com/helm-unittest/helm-unittest.git

- name: Run chart unit tests
id: unittest
run: |
for dir in $(ls -d charts/*/); do
pushd $dir; helm dependencies update; popd
helm unittest $dir
done
continue-on-error: true

- name: Notify Slack of chart unittest failure
if: steps.unittest.outcome == 'failure'
uses: slackapi/slack-github-action@v1.27.0
with:
payload-delimiter: "_"
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Chart unit tests failed. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Fail the workflow if failed unittest
if: steps.unittest.outcome == 'failure'
run: exit 1

install:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ helm-docs
charts/**/charts/
/*.values
/.cr-release-packages

# helm unittest plugin
__snapshot__

bin/**
!bin/README.md

Expand All @@ -10,3 +14,4 @@ _site/
_publish.yml

/.quarto/

17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ We'll try to be as responsive as possible in reviewing and accepting pull reques
- If `index.yaml` gets out of date on the repository, see
[`./scripts/`](./scripts) for a workflow to fix

## Testing

Running the [helm chart unit tests](https://github.com/helm-unittest/helm-unittest):

```
# install the unittest plugin
helm plugin install https://github.com/helm-unittest/helm-unittest.git
# unit tests are defined in `charts/$CHART_NAME/tests`
# test all charts
just test
# run unit tests for a single chart
just test rstudio-connect
```

## Templates

The `rstudio-workbench` and `rstudio-connect` charts both make heavy use of the "templating" feature of the Posit Job
Expand Down
13 changes: 12 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ snapshot-rsw-diff:
fi
done

test chart='all':
#!/usr/bin/env bash
set -xe
if [[ "{{ chart }}" == 'all' ]]; then
for dir in $(ls -d {{ justfile_directory() }}/charts/*/); do
helm unittest $dir
done
else
helm unittest "charts/{{ chart }}"
fi
test-connect-interpreter-versions:
#!/usr/bin/env bash
set -xe
Expand Down Expand Up @@ -118,4 +129,4 @@ push-docs:
# The s3 bucket is s3://docs.rstudio.com/, which is available as https://docs.posit.co/
aws s3 sync ${s3_args[*]:-} \
_site \
"s3://docs.rstudio.com/helm/"
"s3://docs.rstudio.com/helm/"
3 changes: 3 additions & 0 deletions charts/posit-chronicle/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
.idea/
*.tmproj
.vscode/

# chart tests
tests/
2 changes: 1 addition & 1 deletion charts/posit-chronicle/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: posit-chronicle
description: Official Helm chart for Posit Chronicle Server
version: 0.3.3
version: 0.3.4
appVersion: 2024.09.0
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
home: https://www.posit.co
Expand Down
4 changes: 4 additions & 0 deletions charts/posit-chronicle/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.4

- Add helm unit test scaffold.

## 0.3.3

- Move the values files for linting and installation testing outside the chart directory so that we can iterate on them without releasing a new version of the chart
Expand Down
6 changes: 3 additions & 3 deletions charts/posit-chronicle/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Posit Chronicle

![Version: 0.3.3](https://img.shields.io/badge/Version-0.3.3-informational?style=flat-square) ![AppVersion: 2024.09.0](https://img.shields.io/badge/AppVersion-2024.09.0-informational?style=flat-square)
![Version: 0.3.4](https://img.shields.io/badge/Version-0.3.4-informational?style=flat-square) ![AppVersion: 2024.09.0](https://img.shields.io/badge/AppVersion-2024.09.0-informational?style=flat-square)

#### _Official Helm chart for Posit Chronicle Server_

Expand All @@ -25,11 +25,11 @@ To ensure a stable production deployment:

## Installing the chart

To install the chart with the release name `my-release` at version 0.3.3:
To install the chart with the release name `my-release` at version 0.3.4:

```{.bash}
helm repo add rstudio https://helm.rstudio.com
helm upgrade --install my-release rstudio/posit-chronicle --version=0.3.3
helm upgrade --install my-release rstudio/posit-chronicle --version=0.3.4
```

To explore other chart versions, look at:
Expand Down
26 changes: 26 additions & 0 deletions charts/rstudio-connect/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

# chart tests
tests/
6 changes: 3 additions & 3 deletions charts/rstudio-connect/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../rstudio-library
version: 0.1.30
digest: sha256:dcf9d679b18cf99da3781b22797d639a2cbeb47b746dff7e7532b3e55261e938
generated: "2024-05-15T19:57:52.620702-04:00"
version: 0.1.31
digest: sha256:0eb384784157aa97191636a6da495adebef600647566c77a2a0642d3699fdffa
generated: "2024-10-30T16:15:51.145000005-04:00"
4 changes: 2 additions & 2 deletions charts/rstudio-connect/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rstudio-connect
description: Official Helm chart for Posit Connect
version: 0.7.12
version: 0.7.13
apiVersion: v2
appVersion: 2024.09.0
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
Expand All @@ -13,7 +13,7 @@ maintainers:
url: https://github.com/sol-eng
dependencies:
- name: rstudio-library
version: 0.1.30
version: 0.1.31
repository: file://../rstudio-library
annotations:
artifacthub.io/images: |
Expand Down
4 changes: 4 additions & 0 deletions charts/rstudio-connect/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.7.13

- Add initial set of helm unit tests.

## 0.7.12

- Fix a bug where `rbac.serviceAccount.name` was not applied when the job launcher is enabled.
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-connect/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Posit Connect

![Version: 0.7.12](https://img.shields.io/badge/Version-0.7.12-informational?style=flat-square) ![AppVersion: 2024.09.0](https://img.shields.io/badge/AppVersion-2024.09.0-informational?style=flat-square)
![Version: 0.7.13](https://img.shields.io/badge/Version-0.7.13-informational?style=flat-square) ![AppVersion: 2024.09.0](https://img.shields.io/badge/AppVersion-2024.09.0-informational?style=flat-square)

#### _Official Helm chart for Posit Connect_

Expand Down Expand Up @@ -30,11 +30,11 @@ To ensure reproducibility in your environment and insulate yourself from future

## Installing the chart

To install the chart with the release name `my-release` at version 0.7.12:
To install the chart with the release name `my-release` at version 0.7.13:

```{.bash}
helm repo add rstudio https://helm.rstudio.com
helm upgrade --install my-release rstudio/rstudio-connect --version=0.7.12
helm upgrade --install my-release rstudio/rstudio-connect --version=0.7.13
```

To explore other chart versions, look at:
Expand Down
32 changes: 32 additions & 0 deletions charts/rstudio-connect/tests/service-accounts_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
suite: Connect Service Accounts
templates:
- configmap.yaml
- configmap-prestart.yaml
- deployment.yaml
tests:
- it: should set the Connect pod service account when the launcher is enabled
template: deployment.yaml
set:
launcher:
enabled: true
rbac:
create: true
serviceAccount:
name: "connect-service-account"
asserts:
- equal:
path: "spec.template.spec.serviceAccountName"
value: "connect-service-account"
- it: should set the Connect pod service account when the launcher is not enabled
template: deployment.yaml
set:
launcher:
enabled: false
rbac:
create: true
serviceAccount:
name: "connect-service-account"
asserts:
- equal:
path: "spec.template.spec.serviceAccountName"
value: "connect-service-account"
3 changes: 3 additions & 0 deletions charts/rstudio-launcher-rbac/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
.idea/
*.tmproj
.vscode/

# chart tests
tests/
6 changes: 3 additions & 3 deletions charts/rstudio-launcher-rbac/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../rstudio-library
version: 0.1.30
digest: sha256:dcf9d679b18cf99da3781b22797d639a2cbeb47b746dff7e7532b3e55261e938
generated: "2024-05-15T19:57:55.735705-04:00"
version: 0.1.31
digest: sha256:0eb384784157aa97191636a6da495adebef600647566c77a2a0642d3699fdffa
generated: "2024-10-30T16:15:51.566392274-04:00"
4 changes: 2 additions & 2 deletions charts/rstudio-launcher-rbac/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: rstudio-launcher-rbac
description: RBAC definition for the RStudio Job Launcher
type: application
version: 0.2.22
version: 0.2.23
appVersion: 0.2.21
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
sources:
Expand All @@ -13,7 +13,7 @@ maintainers:
url: https://github.com/sol-eng
dependencies:
- name: rstudio-library
version: 0.1.30
version: 0.1.31
repository: file://../rstudio-library
keywords:
- "data science"
Expand Down
4 changes: 4 additions & 0 deletions charts/rstudio-launcher-rbac/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.2.23

- Add helm unit test scaffold.

## 0.2.22

- Move the values files for linting and installation testing outside the chart directory so that we can iterate on them without releasing a new version of the chart
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-launcher-rbac/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rstudio-launcher-rbac

![Version: 0.2.22](https://img.shields.io/badge/Version-0.2.22-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.21](https://img.shields.io/badge/AppVersion-0.2.21-informational?style=flat-square)
![Version: 0.2.23](https://img.shields.io/badge/Version-0.2.23-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.21](https://img.shields.io/badge/AppVersion-0.2.21-informational?style=flat-square)

#### _RBAC definition for the RStudio Job Launcher_

Expand All @@ -21,11 +21,11 @@ To ensure a stable production deployment:

## Installing the chart

To install the chart with the release name `my-release` at version 0.2.22:
To install the chart with the release name `my-release` at version 0.2.23:

```{.bash}
helm repo add rstudio https://helm.rstudio.com
helm upgrade --install my-release rstudio/rstudio-launcher-rbac --version=0.2.22
helm upgrade --install my-release rstudio/rstudio-launcher-rbac --version=0.2.23
```

To explore other chart versions, look at:
Expand Down
3 changes: 3 additions & 0 deletions charts/rstudio-library/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
.idea/
*.tmproj
.vscode/

# chart tests
tests/
4 changes: 2 additions & 2 deletions charts/rstudio-library/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: rstudio-library
description: Helm library helpers for use by official RStudio charts
type: library
version: 0.1.30
appVersion: 0.1.30
version: 0.1.31
appVersion: 0.1.31

icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
home: https://www.rstudio.com
Expand Down
4 changes: 4 additions & 0 deletions charts/rstudio-library/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.31

- Add helm unit test scaffold.

## 0.1.30

- Documentation site updates
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-library/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rstudio-library

![Version: 0.1.30](https://img.shields.io/badge/Version-0.1.30-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.30](https://img.shields.io/badge/AppVersion-0.1.30-informational?style=flat-square)
![Version: 0.1.31](https://img.shields.io/badge/Version-0.1.31-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.31](https://img.shields.io/badge/AppVersion-0.1.31-informational?style=flat-square)

#### _Helm library helpers for use by official RStudio charts_

Expand Down
Loading

0 comments on commit da072f6

Please sign in to comment.