Skip to content

Commit

Permalink
improve release
Browse files Browse the repository at this point in the history
  • Loading branch information
vbehar committed May 7, 2020
1 parent 77af113 commit a049652
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .github/actions/autotag/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'autotag'
description: 'https://github.com/pantheon-systems/autotag'
inputs:
branch:
description: 'Git branch to scan'
required: false
default: 'master'
repo:
description: 'Path to the repo'
required: false
default: './'
pre-release-name:
description: 'create a pre-release tag with this name (can be: alpha|beta|pre|rc)'
required: false
default: ''
pre-release-timestamp:
description: 'create a pre-release tag and append a timestamp (can be: datetime|epoch)'
required: false
default: ''
dry-run:
description: 'Just output the next version, don''t autotag'
required: false
default: ''
outputs:
version:
description: 'The new version'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}
11 changes: 9 additions & 2 deletions .github/actions/autotag/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/sh
set -eu

cd "$GITHUB_WORKSPACE"
cd "${GITHUB_WORKSPACE}"

/autotag "$@"
if [ -n "${INPUT_DRY_RUN}" ]; then
echo "Running in dry-run mode"
DRY_RUN="-n"
fi

version=$(/autotag --branch=${INPUT_BRANCH} --repo=${INPUT_REPO} --pre-release-name=${INPUT_PRE_RELEASE_NAME} --pre-release-timestamp=${INPUT_PRE_RELEASE_TIMESTAMP} ${DRY_RUN})

echo "::set-output name=version::$version"
17 changes: 17 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ jobs:
token: ${{ secrets.GH_TOKEN }}
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Next Version
id: nextversion
uses: ./.github/actions/autotag/
with:
dry-run: true
- name: Update plugin.yaml version
uses: mikefarah/yq@master
with:
cmd: yq w -i plugin.yaml 'version' "${{ steps.nextversion.outputs.version }}"
- name: Commit
uses: EndBug/add-and-commit@v4
with:
add: plugin.yaml
message: 'Release ${{ steps.nextversion.outputs.version }}'
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Tag
uses: ./.github/actions/autotag/
- name: Push
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
branch: "release/${{ steps.nextversion.outputs.version }}"
tags: true
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tests:
and run:
```
$ helm unittest3 $YOUR_CHART
$ helm unittest $YOUR_CHART
```

Now there is your first test! ;)
Expand All @@ -60,14 +60,14 @@ Now there is your first test! ;)
The test suite file is written in pure YAML, and default placed under the `tests/` directory of the chart with suffix `_test.yaml`. You can also have your own suite files arrangement with `-f, --file` option of cli set as the glob patterns of test suite files related to chart directory, like:

```bash
$ helm unittest3 -f 'my-tests/*.yaml' -f 'more-tests/*.yaml' my-chart
$ helm unittest -f 'my-tests/*.yaml' -f 'more-tests/*.yaml' my-chart
```
Check [DOCUMENT](./DOCUMENT.md) for more details about writing tests.

## Usage

```
$ helm unittest3 [flags] CHART [...]
$ helm unittest [flags] CHART [...]
```

This renders your charts locally (without tiller) and runs tests
Expand Down Expand Up @@ -107,7 +107,7 @@ tests:
The `matchSnapshot` assertion validate the content rendered the same as cached last time. It fails if the content changed, and you should check and update the cache with `-u, --update-snapshot` option of cli.

```
$ helm unittest3 -u my-chart
$ helm unittest -u my-chart
```
The cache files is stored as `__snapshot__/*_test.yaml.snap` at the directory your test file placed, you should add them in version control with your chart.
Expand Down
12 changes: 8 additions & 4 deletions install_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ if [ -n "${HELM_LINTER_PLUGIN_NO_INSTALL_HOOK}" ]; then
exit 0
fi

# shellcheck disable=SC2002
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
version="$(git describe --tags --exact-match 2>/dev/null)"
if [ -n "$version" ]; then
version="${version:1}"
else
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
fi
echo "Downloading and installing helm3-unittest v${version} ..."

url=""
Expand Down Expand Up @@ -37,7 +41,7 @@ else
wget -q "${url}" -O "releases/v${version}.tar.gz"
fi
tar xzf "releases/v${version}.tar.gz" -C "releases/v${version}"
mv "releases/v${version}/helm3-unittest" "bin/unittest3" || \
mv "releases/v${version}/helm3-unittest.exe" "bin/unittest3"
mv "releases/v${version}/helm3-unittest" "bin/unittest" || \
mv "releases/v${version}/helm3-unittest.exe" "bin/unittest"
mv "releases/v${version}/plugin.yaml" .
mv "releases/v${version}/README.md" .
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "unittest3"
name: "unittest"
version: "1.0.3"
usage: "unittest for helm 3 charts"
description: "Unit test for helm 3 charts in YAML with ease to keep your chart functional and robust."
ignoreFlags: false
command: "$HELM_PLUGIN_DIR/bin/unittest3"
command: "$HELM_PLUGIN_DIR/bin/unittest"
hooks:
install: "cd $HELM_PLUGIN_DIR; ./install_plugin.sh"
update: "cd $HELM_PLUGIN_DIR; ./install_plugin.sh"

0 comments on commit a049652

Please sign in to comment.