Skip to content

Hackaton for release toolkit #565

Hackaton for release toolkit

Hackaton for release toolkit #565

Workflow file for this run

name: Self-test
on:
pull_request:
push:
branches:
- main
jobs:
is-held:
name: is-held action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > changelog.yaml <<EOF
held: true
EOF
cat > CHANGELOG.md <<EOF
# Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Added new feature here
## 1.0.0 - 2017-06-20
### Added
- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
EOF
- uses: ./is-held
id: held
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
- run: |
if [[ "${{ steps.held.outputs.is-held }}" != "true" ]]; then
echo "is-held should have returned true" >&2
exit 1
fi
is-empty:
name: is-empty action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > changelog.yaml <<EOF
notes: ""
changes: []
dependencies: []
EOF
- uses: ./is-empty
id: empty
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
- run: |
if [[ "${{ steps.empty.outputs.is-empty }}" != "true" ]]; then
echo "is-empty should have returned true" >&2
exit 1
fi
- name: Update changelog.yaml
id: repo-update
shell: bash
run: |
cd $MOCK_REPO
cat > changelog.yaml <<EOF
notes: ""
changes: []
dependencies:
- name: github.com/stretchr/testify
from: 1.8.1
to: 1.8.2
changelog: https://github.com/stretchr/testify/releases/tag/v1.8.2
meta:
pr: "212"
commit: 2394d3e450a2992224c1c56a20df1ba0e06bdf59
EOF
- uses: ./is-empty
id: empty-updated
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
- run: |
if [[ "${{ steps.empty-updated.outputs.is-empty }}" != "false" ]]; then
echo "is-empty should have returned false" >&2
exit 1
fi
generate-yaml:
name: generate-yaml action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > CHANGELOG.md <<EOF
# Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Enhancements
- Added new feature here
## 1.0.0 - 2017-06-20
### Added
- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).
EOF
- uses: ./generate-yaml
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
markdown: ${{ env.MOCK_REPO }}/CHANGELOG.md
git-root: ${{ env.MOCK_REPO }}
- run: |
cat $MOCK_REPO/changelog.yaml
if [[ $(cat $MOCK_REPO/changelog.yaml | wc -c) -eq 0 ]]; then
echo "Changelog.yaml should not be empty" >&2
exit 1
fi
if grep -e 'changes: \[\]' $MOCK_REPO/changelog.yaml; then
echo "Changelog.yaml should not have an empty changes section" >&2
exit 2
fi
generate-yaml-empty:
name: generate-yaml action empty changelog
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > CHANGELOG.md <<EOF
# Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
EOF
- uses: ./generate-yaml
id: generate-yaml
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
markdown: ${{ env.MOCK_REPO }}/CHANGELOG.md
git-root: ${{ env.MOCK_REPO }}
- run: |
if [[ "${{ steps.generate-yaml.outputs.empty-changelog }}" != "true" ]]; then
echo "empty-changelog should have returned true" >&2
exit 1
fi
next-version:
name: next-version action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
git tag v1.2.3
cat > changelog.yaml <<EOF
changes:
- type: breaking
message: this is broken
EOF
- uses: ./next-version
id: next-version
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
git-root: ${{ env.MOCK_REPO }}
- run: |
errors=0
if [[ "${{ steps.next-version.outputs.next-version }}" != "v2.0.0" ]]; then
echo "next-version should have returned v2.0.0" >&2
(( errors++ ))
fi
if [[ "${{ steps.next-version.outputs.next-version-major }}" != "v2" ]]; then
echo "next-version should have returned v2.0.0" >&2
(( errors++ ))
fi
if [[ "${{ steps.next-version.outputs.next-version-major-minor }}" != "v2.0" ]]; then
echo "next-version should have returned v2.0.0" >&2
(( errors++ ))
fi
exit ${errors}
link-dependencies:
name: link-dependencies action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > dictionary.yaml <<EOF
dictionary:
infrastructure-agent: "https://github.com/newrelic/infrastructure-agent/releases/tag/{{.To.Original}}"
EOF
cat > changelog.yaml <<EOF
changes:
- type: breaking
message: this is broken
dependencies:
- name: infrastructure-agent
to: v1.2.3
- name: github.com/spf13/viper
from: 1.14.0
to: 1.15.0
EOF
- uses: ./link-dependencies
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
dictionary: ${{ env.MOCK_REPO }}/dictionary.yaml
- run: |
cat $MOCK_REPO/changelog.yaml
if ! grep -e 'changelog: https://github.com/newrelic/infrastructure-agent/releases/tag/v1.2.3' $MOCK_REPO/changelog.yaml; then
echo "Changelog.yaml should have infrastructure-agent changelog linked" >&2
exit 2
fi
render-changelog:
name: render-changelog action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > changelog.yaml <<EOF
notes: |-
### Important announcement (note)
This is a release note
changes:
- type: breaking
message: Support has been removed
EOF
cat > expected-changelog.md <<EOF
## v1.2.3 - $(date +%Y-%m-%d)
### Important announcement (note)
This is a release note
### ⚠️️ Breaking changes ⚠️
- Support has been removed
EOF
- uses: ./render
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
markdown: ${{ env.MOCK_REPO }}/CHANGELOG.partial.md
version: v1.2.3
- run: |
cat $MOCK_REPO/expected-changelog.md
if ! cmp --silent ${{ env.MOCK_REPO }}/expected-changelog.md ${{ env.MOCK_REPO }}/CHANGELOG.partial.md; then
echo "CHANGELOG.partial.md should be equal to the expected" >&2
exit 2
fi
update-markdown:
name: update-markdown action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > changelog.yaml <<EOF
notes: |-
### Important announcement (note)
This is a release note
changes:
- type: breaking
message: Support has been removed
EOF
cat > existing.md <<EOF
# Changelog
This is based on blah blah blah
## v1.2.3 - 20YY-DD-MM
### Enhancements
- This is in the past and should be preserved
EOF
cat > expected-changelog.md <<EOF
# Changelog
This is based on blah blah blah
## v1.2.3 - $(date +%Y-%m-%d)
### Important announcement (note)
This is a release note
### ⚠️️ Breaking changes ⚠️
- Support has been removed
## v1.2.3 - 20YY-DD-MM
### Enhancements
- This is in the past and should be preserved
EOF
- uses: ./update-markdown
with:
yaml: ${{ env.MOCK_REPO }}/changelog.yaml
markdown: ${{ env.MOCK_REPO }}/existing.md
version: v1.2.3
- run: |
cat $MOCK_REPO/existing.md
if ! cmp ${{ env.MOCK_REPO }}/expected-changelog.md ${{ env.MOCK_REPO }}/existing.md; then
echo "Changelog md was not updated to its expected contents" >&2
exit 2
fi
validate-markdown:
name: validate markdown action
runs-on: ubuntu-latest
env:
MOCK_REPO: ./mock_repo
steps:
- uses: actions/checkout@v4
- name: Configure test repo
id: repo
shell: bash
run: |
mkdir $MOCK_REPO
cd $MOCK_REPO
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git init
for i in 1 2 3; do
touch file$i
git add file$i
git commit -m commit_$i
done
cat > changelog.md <<EOF
# Wrong-Changelog
This is based on blah blah blah
## v1.2.3 - 20YY-DD-MM
### Enhancements
- This is in the past and should be preserved
EOF
- uses: ./validate-markdown
id: validate-markdown
with:
markdown: ${{ env.MOCK_REPO }}/changelog.md
exit-code: 0
- run: |
if [[ "${{ steps.validate-markdown.outputs.valid }}" != "false" ]]; then
echo "valid should have returned false" >&2
exit 1
fi