Skip to content

Commit

Permalink
Add Go, Java Native Image, Procfile to builder (#3)
Browse files Browse the repository at this point in the history
* add scripts, workflows, initial builder.toml

* remove go and procfile buildpacks from builder

since both are known incompatible

* fix tags in push image workflow

* correct go module name

* add Golang and Procfile, remove Java Native Image

* run failing Java Native Image tests

* Updates builder.toml and runs all tests

* Use parameterized push image workflow

Co-authored-by: Forest Eckhardt <[email protected]>
  • Loading branch information
Frankie G-J and ForestEckhardt authored Jul 20, 2022
1 parent c3dcfbd commit 6ead10c
Show file tree
Hide file tree
Showing 47 changed files with 5,064 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/.syncignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CODEOWNERS
dependabot.yml
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @paketo-buildpacks/builders-maintainers
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

---
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
30 changes: 30 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- name: status/possible-priority
description: This issue is ready to work and should be considered as a potential priority
color: F9D0C4
- name: status/prioritized
description: This issue has been triaged and resolving it is a priority
color: BFD4F2
- name: status/blocked
description: This issue has been triaged and resolving it is blocked on some other issue
color: 848978
- name: bug
description: Something isn't working
color: d73a4a
- name: enhancement
description: A new feature or request
color: a2eeef
- name: documentation
description: This issue relates to writing documentation
color: D4C5F9
- name: semver:major
description: A change requiring a major version bump
color: 6b230e
- name: semver:minor
description: A change requiring a minor version bump
color: cc6749
- name: semver:patch
description: A change requiring a patch version bump
color: f9d0c4
- name: good first issue
description: A good first issue to get started with
color: d3fc03
25 changes: 25 additions & 0 deletions .github/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Config for https://github.com/release-drafter/release-drafter
name-template: '$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
filter-by-commitish: true
commitish: main

change-template: '- $TITLE [#$NUMBER] by [@$AUTHOR](https://github.com/$AUTHOR)'
template: |
## Full Changelog
Following pull requests got merged for this release:
$CHANGES
version-resolver:
major:
labels:
- 'semver:major'
minor:
labels:
- 'semver:minor'
patch:
labels:
- 'semver:patch'
default: patch
69 changes: 69 additions & 0 deletions .github/workflows/approve-bot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Approve Bot PRs and Enable Auto-Merge

on:
workflow_run:
workflows: ["Test Pull Request"]
types:
- completed

jobs:
download:
name: Download PR Artifact
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
pr-author: ${{ steps.pr-data.outputs.author }}
pr-number: ${{ steps.pr-data.outputs.number }}
steps:
- name: 'Download artifact'
uses: paketo-buildpacks/github-config/actions/pull-request/download-artifact@main
with:
name: "event-payload"
repo: ${{ github.repository }}
run_id: ${{ github.event.workflow_run.id }}
workspace: "/github/workspace"
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
- id: pr-data
run: |
echo "::set-output name=author::$(cat event.json | jq -r '.pull_request.user.login')"
echo "::set-output name=number::$(cat event.json | jq -r '.pull_request.number')"
approve:
name: Approve Bot PRs
needs: download
if: ${{ needs.download.outputs.pr-author == 'paketo-bot' || needs.download.outputs.pr-author == 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Check Commit Verification
id: unverified-commits
uses: paketo-buildpacks/github-config/actions/pull-request/check-unverified-commits@main
with:
token: ${{ secrets.PAKETO_BOT_REVIEWER_GITHUB_TOKEN }}
repo: ${{ github.repository }}
number: ${{ needs.download.outputs.pr-number }}

- name: Check for Human Commits
id: human-commits
uses: paketo-buildpacks/github-config/actions/pull-request/check-human-commits@main
with:
token: ${{ secrets.PAKETO_BOT_REVIEWER_GITHUB_TOKEN }}
repo: ${{ github.repository }}
number: ${{ needs.download.outputs.pr-number }}

- name: Checkout
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
uses: actions/checkout@v3

- name: Approve
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
uses: paketo-buildpacks/github-config/actions/pull-request/approve@main
with:
token: ${{ secrets.PAKETO_BOT_REVIEWER_GITHUB_TOKEN }}
number: ${{ needs.download.outputs.pr-number }}

- name: Enable Auto-Merge
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
run: |
gh pr merge ${{ needs.download.outputs.pr-number }} --auto --rebase
env:
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
96 changes: 96 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Create Release

on:
push:
branches:
- main

concurrency: release

jobs:
smoke:
name: Smoke Test
runs-on: ubuntu-latest
outputs:
release_notes: ${{ steps.notes.outputs.body }}
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x

- name: Checkout
uses: actions/checkout@v3

- name: Get pack version
id: pack-version
run: |
version=$(jq -r .pack "scripts/.util/tools.json")
echo "::set-output name=version::${version#v}"
- name: Install Global Pack
uses: buildpacks/github-actions/setup-pack@main
with:
pack-version: ${{ steps.pack-version.outputs.version }}

- name: Run Smoke Tests
run: ./scripts/smoke.sh --name builder

- name: Generate Release Notes
id: notes
run: |
notes="$(pack inspect-builder builder | grep -v 'Inspecting builder' \
| grep -v 'REMOTE:' \
| grep -v 'LOCAL:' \
| grep -v '\(not present\)' \
| grep -v 'Warning' \
| sed -e '/./,$!d' \
| awk -F, '{printf "%s\\n", $0}')"
echo "::set-output name=body::${notes}"
release:
name: Release
runs-on: ubuntu-latest
needs: smoke
steps:
- name: Checkout With History
uses: actions/checkout/@v2
with:
fetch-depth: 0 # gets full history

- name: Compare With Previous Release
id: compare_previous_release
run: |
if [ -z "$(git diff $(git describe --tags --abbrev=0) -- builder.toml)" ]
then
echo "::set-output name=builder_changes::false"
else
echo "::set-output name=builder_changes::true"
fi
- name: Publish Release
id: publish
if: ${{ steps.compare_previous_release.outputs.builder_changes == 'true' }}
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter-config.yml
publish: true
env:
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

- name: Update Release Notes
if: ${{ steps.compare_previous_release.outputs.builder_changes == 'true' }}
run: |
set -e
payload="{\"body\" : \"\`\`\`\n${RELEASE_BODY}\n\`\`\`\"}"
curl --fail \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
-d "${payload}"
env:
RELEASE_ID: ${{ steps.publish.outputs.id }}
RELEASE_BODY: ${{ needs.smoke.outputs.release_notes }}
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/lint-yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint Workflows

on:
pull_request:
paths:
- '.github/**.yml'
- '.github/**.yaml'

jobs:
lintYaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Checkout github-config
uses: actions/checkout@v3
with:
repository: paketo-buildpacks/github-config
path: github-config

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML files
run: yamllint ./.github -c github-config/.github/.yamllint
52 changes: 52 additions & 0 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Push Builder Image

on:
release:
types:
- published

jobs:
push:
name: Push
runs-on: ubuntu-latest
steps:

- name: Parse Event
id: event
run: |
echo "::set-output name=tag::$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)"
- name: Checkout
uses: actions/checkout@v2

- name: Get pack version
id: pack-version
run: |
version=$(jq -r .pack "scripts/.util/tools.json")
echo "::set-output name=version::${version#v}"
- name: Install Global Pack
uses: buildpacks/github-actions/setup-pack@main
with:
pack-version: ${{ steps.pack-version.outputs.version }}

- name: Create Builder Image
run: |
pack builder create builder --config builder.toml
- name: Push To Dockerhub
env:
PAKETO_BUILDPACKS_DOCKERHUB_USERNAME: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}
PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }}
DOCKERHUB_ORG: "paketobuildpacks"
run: |
# Strip off the Github org prefix from repo name
# paketo-buildpacks/builder-with-some-name --> builder-with-some-name
registry_repo=$(echo "${{ github.repository }}" | sed 's/^.*\///')
echo "${PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD}" | docker login --username "${PAKETO_BUILDPACKS_DOCKERHUB_USERNAME}" --password-stdin
docker tag builder "${DOCKERHUB_ORG}/${registry_repo}:latest"
docker tag builder "${DOCKERHUB_ORG}/${registry_repo}:${{ steps.event.outputs.tag }}"
docker push "${DOCKERHUB_ORG}/${registry_repo}:latest"
docker push "${DOCKERHUB_ORG}/${registry_repo}:${{ steps.event.outputs.tag }}"
17 changes: 17 additions & 0 deletions .github/workflows/synchronize-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Synchronize Labels
"on":
push:
branches:
- main
paths:
- .github/labels.yml
jobs:
synchronize:
name: Synchronize Labels
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ github.token }}
33 changes: 33 additions & 0 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test Pull Request

on:
pull_request:
branches:
- main

jobs:

smoke:
name: Smoke Test
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x

- name: Checkout
uses: actions/checkout@v3

- name: Run Smoke Tests
run: ./scripts/smoke.sh

upload:
name: Upload Workflow Event Payload
runs-on: ubuntu-latest
steps:
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: event-payload
path: ${{ github.event_path }}
Loading

0 comments on commit 6ead10c

Please sign in to comment.