build(deps): bump golang from 1.21.2-alpine to 1.21.3-alpine (#173) #496
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |
exit-code: 0 | |
- 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: | | |
if [[ "${{ steps.next-version.outputs.next-version }}" != "v2.0.0" ]]; then | |
echo "next-version should have returned v2.0.0" >&2 | |
exit 1 | |
fi | |
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 | |
contrib-ohi-release-notes: | |
name: validate ohi-release-notes (contrib action) | |
runs-on: ubuntu-latest | |
env: | |
MOCK_REPO_ACTION: ./mock_repo_action | |
MOCK_REPO_SCRIPT: ./mock_repo_script | |
ACTION_OUTPUTS: ./action_outputs | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure test repo | |
shell: bash | |
run: | | |
# MOCK_REPO_SCRIPT is not needed as it is copied from ACTION one. | |
mkdir -pv "${MOCK_REPO_ACTION}" "${ACTION_OUTPUTS}" | |
cd "${MOCK_REPO_ACTION}" | |
git config --global user.email "[email protected]" | |
git config --global user.name "Your Name" | |
git init | |
cat > CHANGELOG.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 | |
git add CHANGELOG.md | |
for i in 1 2 3; do | |
touch file$i | |
git add file$i | |
git commit -m commit_$i | |
done | |
git tag 1.2.3 | |
touch dependencies | |
git add dependencies | |
git commit -m "chore(deps): bump newrelic/infrastructure from 0.0.0 to 0.0.1 (#1)" --author="dependabot[bot] <[email protected]>" | |
touch dependencies1 | |
git add dependencies1 | |
git commit -m "chore(deps): bump github.com/stretchr/testify from 1.7.0 to 1.8.0" --author="dependabot[bot] <[email protected]>" | |
touch dependencies-skip1 | |
git add dependencies-skip1 | |
git commit -m "chore(deps): bump newrelic/infrastructure from 0.0.1 to 0.0.2 (#2)" --author="dependabot[bot] <[email protected]>" | |
mkdir dependencies-repo-skip | |
touch dependencies-repo-skip/dependencies-skip2 | |
git add dependencies-repo-skip/dependencies-skip2 | |
git commit -m "chore(deps): bump newrelic/infrastructure from 0.0.2 to 0.0.3 (#3)" --author="dependabot[bot] <[email protected]>" | |
mkdir dependencies-repo | |
touch dependencies-repo/dependencies | |
git add dependencies-repo/dependencies | |
git commit -m "chore(deps): bump newrelic/nri-docker from 0.0.3 to 0.0.4 (#4)" --author="dependabot[bot] <[email protected]>" | |
cat > CHANGELOG.md <<EOF | |
# Changelog | |
This is based on blah blah blah | |
## Unreleased | |
### Enhancement | |
- test | |
## v1.2.3 - 20YY-DD-MM | |
### Enhancements | |
- This is in the past and should be preserved | |
EOF | |
cd $OLDPWD | |
cp -r "${MOCK_REPO_ACTION}" "${MOCK_REPO_SCRIPT}" | |
- name: Expected CHANGELOG | |
shell: bash | |
run: | | |
cat > expected-changelog.md <<EOF | |
# Changelog | |
This is based on blah blah blah | |
## Unreleased | |
## v1.3.0 - $(date +%Y-%m-%d) | |
### π Enhancements | |
- test | |
### βοΈ Dependencies | |
- Upgraded newrelic/infrastructure from 0.0.0 to 0.0.1 - [Changelog π](https://github.com/newrelic/infrastructure-agent/releases/tag/0.0.1) | |
- Upgraded newrelic/nri-docker from 0.0.3 to 0.0.4 - [Changelog π](https://github.com/newrelic/nri-docker/releases/tag/0.0.4) | |
## v1.2.3 - 20YY-DD-MM | |
### Enhancements | |
- This is in the past and should be preserved | |
EOF | |
- name: Expected partial CHANGELOG | |
shell: bash | |
run: | | |
cat > expected-partial.md <<EOF | |
## v1.3.0 - $(date +%Y-%m-%d) | |
### π Enhancements | |
- test | |
### βοΈ Dependencies | |
- Upgraded newrelic/infrastructure from 0.0.0 to 0.0.1 - [Changelog π](https://github.com/newrelic/infrastructure-agent/releases/tag/0.0.1) | |
- Upgraded newrelic/nri-docker from 0.0.3 to 0.0.4 - [Changelog π](https://github.com/newrelic/nri-docker/releases/tag/0.0.4) | |
EOF | |
- name: Run action | |
uses: ./contrib/ohi-release-notes | |
id: ohi-release-notes | |
with: | |
git-root: ${{ env.MOCK_REPO_ACTION }} | |
excluded-files: dependencies-skip1 | |
excluded-dirs: dependencies-repo-skip | |
included-dirs: dependencies-repo | |
included-files: dependencies,dependencies1 | |
- name: Run script | |
run: | | |
cd "${{ env.MOCK_REPO_SCRIPT }}" | |
# CLI autodetects whether it is running on GHA or not. If we let GHA set this to true, as it normally does, | |
# tests cases where GITHUB_ACTIONS is expected to be unset would fail. | |
GITHUB_ACTIONS=false "${GITHUB_WORKSPACE}/contrib/ohi-release-notes/run.sh" --included-dirs dependencies-repo --included-files dependencies,dependencies1 --excluded-files dependencies-skip1 --excluded-dirs dependencies-repo-skip | |
- name: Action outputs | |
working-directory: ${{ env.ACTION_OUTPUTS }} | |
run: | | |
echo -ne "${{ steps.ohi-release-notes.outputs.changelog }}" > CHANGELOG.md | |
echo -ne "${{ steps.ohi-release-notes.outputs.changelog-partial }}" > CHANGELOG.partial.md | |
- name: Asserts | |
run: | | |
exit_status=0 | |
echo "Action's CHANGELOG.md should be equal" | |
echo RESULT: | |
cat "${{ env.MOCK_REPO_ACTION }}/CHANGELOG.md" | |
echo EXPECTED: | |
cat expected-changelog.md | |
echo TEST: | |
if cmp --silent expected-changelog.md ${{ env.MOCK_REPO_ACTION }}/CHANGELOG.md; then | |
echo PASS | |
else | |
echo FAIL - diff between expected and the output: | |
diff expected-changelog.md ${{ env.MOCK_REPO_ACTION }}/CHANGELOG.md | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "script's CHANGELOG.md should be equal" | |
echo RESULT: | |
cat "${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.md" | |
echo EXPECTED: | |
cat expected-changelog.md | |
echo TEST: | |
if cmp --silent expected-changelog.md ${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.md; then | |
echo PASS | |
else | |
echo FAIL - diff between expected and the output: | |
diff expected-changelog.md ${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.md | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "script's CHANGELOG.md should be equal" | |
echo RESULT: | |
cat "${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.md" | |
echo EXPECTED: | |
cat expected-changelog.md | |
echo TEST: | |
if cmp --silent expected-changelog.md ${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.md; then | |
echo PASS | |
else | |
echo FAIL - diff between expected and the output: | |
diff expected-changelog.md ${{ env.ACTION_OUTPUTS }}/CHANGELOG.md | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "Action's CHANGELOG.partial.md should be equal" | |
echo RESULT: | |
cat "${{ env.MOCK_REPO_ACTION }}/CHANGELOG.partial.md" | |
echo EXPECTED: | |
cat expected-partial.md | |
echo TEST: | |
if cmp --silent expected-partial.md ${{ env.MOCK_REPO_ACTION }}/CHANGELOG.partial.md; then | |
echo PASS | |
else | |
echo FAIL - diff between expected and the output: | |
diff expected-partial.md ${{ env.MOCK_REPO_ACTION }}/CHANGELOG.partial.md | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "script's CHANGELOG.partial.md should be equal" | |
echo RESULT: | |
cat "${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.partial.md" | |
echo EXPECTED: | |
cat expected-partial.md | |
echo TEST: | |
if cmp --silent expected-partial.md ${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.partial.md; then | |
echo PASS | |
else | |
echo FAIL - diff between expected and the output: | |
diff expected-partial.md ${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.partial.md | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "script's CHANGELOG.partial.md should be equal" | |
echo RESULT: | |
cat "${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.partial.md" | |
echo EXPECTED: | |
cat expected-partial.md | |
echo TEST: | |
if cmp --silent expected-partial.md ${{ env.MOCK_REPO_SCRIPT }}/CHANGELOG.partial.md; then | |
echo PASS | |
else | |
echo FAIL - diff between expected and the output: | |
diff expected-partial.md ${{ env.ACTION_OUTPUTS }}/CHANGELOG.partial.md | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "action output 'next-version' return the expected value" | |
echo EXPECTED: | |
echo "v1.3.0" | |
echo RESULT: | |
echo "${{ steps.ohi-release-notes.outputs.next-version }}" | |
echo TEST: | |
if [ "${{ steps.ohi-release-notes.outputs.next-version }}" = "v1.3.0" ] ; then | |
echo PASS | |
else | |
echo FAIL - action output 'next-version' does not return the expected value | |
((exit_status++)) | |
fi | |
echo ================================================================= | |
echo "action output 'release-title' return the expected value" | |
echo EXPECTED: | |
echo "v1.3.0 - $(date +%Y-%m-%d)" | |
echo RESULT: | |
echo "${{ steps.ohi-release-notes.outputs.release-title }}" | |
echo TEST: | |
if [ "${{ steps.ohi-release-notes.outputs.release-title }}" = "v1.3.0 - $(date +%Y-%m-%d)" ] ; then | |
echo PASS | |
else | |
echo FAIL - action output 'release-title' does not return the expected value | |
((exit_status++)) | |
fi | |
exit $exit_status |