Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
# the repo. Unless a later match takes precedence.

* @newrelic/coreint
* @newrelic/caos
16 changes: 12 additions & 4 deletions .github/workflows/push_pr.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
name: Push/PR pipeline
on:
pull_request:
push:
branches:
- main

jobs:
rebase:
name: Branch needs rebase
runs-on: ubuntu-latest
if: github.event.pull_request
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -51,8 +47,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if CHANGELOG is valid
uses: ./validate-markdown
- name: Generate YAML for the changelog
uses: ./generate-yaml
- name: Check if the release is not needed
id: empty
uses: ./is-empty
- run: |
if [[ "${{ steps.empty.outputs.is-empty }}" == "true" ]]; then
echo "Release is empty, failing" >&2
exit 1
fi

static-analysis:
name: Static analysis and linting
Expand Down
251 changes: 0 additions & 251 deletions .github/workflows/self_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ jobs:
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
Expand Down Expand Up @@ -503,253 +502,3 @@ jobs:
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 "you@example.com"
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] <db@users.noreply.github.com>"

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] <db@users.noreply.github.com>"

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] <db@users.noreply.github.com>"

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] <db@users.noreply.github.com>"

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 1.8.26 (#4)" --author="dependabot[bot] <db@users.noreply.github.com>"

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

## v2.0.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 1.8.26 - [Changelog 🔗](https://github.com/newrelic/nri-docker/releases/tag/v1.8.26)

## 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
## v2.0.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 1.8.26 - [Changelog 🔗](https://github.com/newrelic/nri-docker/releases/tag/v1.8.26)
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 "v2.0.0"
echo RESULT:
echo "${{ steps.ohi-release-notes.outputs.next-version }}"
echo TEST:
if [ "${{ steps.ohi-release-notes.outputs.next-version }}" = "v2.0.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 "v2.0.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 }}" = "v2.0.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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

Unreleased section should follow [Release Toolkit](https://github.com/newrelic/release-toolkit#render-markdown-and-update-markdown)

## Unreleased

### Notes

`ohi-release-notes` action was only used by Coreint team and it has been moved to their repository:
[`coreint-automation` PR](https://github.com/newrelic/coreint-automation/pull/83)

`generate-yaml` failed to create an empty YAML by default. The composable nature of `release-toolkit`
encourages the user to hack the YAML if needed. This is also needed so an empty YAML is there for the
other actions like `is-empty` or `is-held` to work properly.

`next-version` should also follow the composable nature of `release-toolkit`. But this part of the tool
should fail if there is no new version in case a user hack the YAML to a point that is not bumping the
version. Not failing can lead scripts to override an already existing version. This is also a change
on the default behavior.

### Breaking
- `ohi-release-notes` action has been moved to another repository
- `generate-yaml` does not fail to create an empty YAML by default
- `next-version` fail if there are no version to be bumped

### Bugfix
- Upgrade golang and project dependencies to the latest version
- Change use of deprecated print `::set-output` to write to `$GITHUB_OUTPUT` file

## v1.2.0 - 2024-08-09

### 🚀 Enhancements
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Builder for GHA does not use BUILDKIT, so we cannot use a multiarch-friendly builder image.
# FROM --platform=$BUILDPLATFORM golang:1.18-alpine as builder
FROM golang:1.22.0-alpine as builder
FROM golang:1.23.2-alpine as builder

WORKDIR /rt
COPY go.* ./
Expand All @@ -12,6 +12,6 @@ COPY src src

RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /bin/rt

FROM alpine as runner
FROM alpine:3.20.3 as runner
COPY --from=builder /bin/rt /bin/rt
ENTRYPOINT [ "/bin/rt" ]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ name: Release workflow
on:
workflow-dispatch:
jobs:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # This is important to have all the commits and tags
- name: Generate transient changelog.yaml
uses: newrelic/release-toolkit/generate-yaml@v1
with:
Expand Down
Loading