Skip to content

Commit

Permalink
Add build, detect, and integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuatcasey committed Mar 31, 2022
1 parent 6793424 commit 1fa118c
Show file tree
Hide file tree
Showing 47 changed files with 5,861 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/.patch_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.github/.patch_files
.github/.syncignore
.github/CODEOWNERS
.github/dependabot.yml
.github/labels.yml
.github/workflows/approve-bot-pr.yml
.github/workflows/auto-merge.yml
.github/workflows/check-pr-labels.yml
.github/workflows/codeql-analysis.yml
.github/workflows/label-pr.yml
.github/workflows/lint-yaml.yml
.github/workflows/lint.yml
.github/workflows/synchronize-labels.yml
.github/workflows/test-pull-request.yml
.github/workflows/update-dependencies.yml
.github/workflows/update-github-config.yml
.gitignore
LICENSE
NOTICE
README.md
scripts/.util/print.sh
scripts/.util/tools.json
scripts/.util/tools.sh
scripts/integration.sh
scripts/unit.sh
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
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
62 changes: 62 additions & 0 deletions .github/workflows/approve-bot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Approve Bot PRs

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@v2

- 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 }}
44 changes: 44 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Auto-Merge

on:
pull_request_review:
types:
- submitted

jobs:
automerge:
name: Merge or Rebase
if: ${{ github.event.review.user.login == 'paketo-bot-reviewer' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Fetch Pull Request Details
id: pull_request
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
run: |
payload="$(
curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${NUMBER}" \
--silent \
--location \
--header "Authorization: token ${GITHUB_TOKEN}"
)"
echo "::set-output name=mergeable_state::$(echo "${payload}" | jq -r -c .mergeable_state)"
- name: Merge
if: ${{ steps.pull_request.outputs.mergeable_state == 'clean' || steps.pull_request.outputs.mergeable_state == 'unstable' }}
uses: paketo-buildpacks/github-config/actions/pull-request/merge@main
with:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}

- name: Rebase
if: ${{ steps.pull_request.outputs.mergeable_state == 'behind' }}
uses: paketo-buildpacks/github-config/actions/pull-request/rebase@main
with:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
24 changes: 24 additions & 0 deletions .github/workflows/check-pr-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Validate PR Labels
on:
pull_request:
branches:
- main
types:
- synchronize
- opened
- reopened
- labeled
- unlabeled

concurrency: pr_labels

jobs:
semver:
name: Ensure Minimal Semver Labels
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v1
with:
count: 1
labels: semver:major, semver:minor, semver:patch
mode: exactly
35 changes: 35 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 0 * * *' # Once a day at midnight

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language:
- 'go'

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
112 changes: 112 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Create or Update Draft Release

on:
push:
branches:
- main
repository_dispatch:
types: [ version-bump ]
workflow_dispatch:
inputs:
version:
description: 'Version of the release to cut (e.g. 1.2.3)'
required: false

concurrency: release

jobs:
unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
- name: Checkout
uses: actions/checkout@v2
- name: Run Unit Tests
run: ./scripts/unit.sh

integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: unit
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
- name: Checkout
uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Run Integration Tests
run: ./scripts/integration.sh --use-token
env:
GIT_TOKEN: ${{ github.token }}

release:
name: Release
runs-on: ubuntu-latest
needs: integration
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
- name: Checkout
uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Reset Draft Release
id: reset
uses: paketo-buildpacks/github-config/actions/release/reset-draft@main
with:
repo: ${{ github.repository }}
token: ${{ github.token }}
- name: Calculate Semver Tag
if: github.event.inputs.version == ''
id: semver
uses: paketo-buildpacks/github-config/actions/tag/calculate-semver@main
with:
repo: ${{ github.repository }}
token: ${{ github.token }}
ref-name: ${{ github.ref_name }}
- name: Set Release Tag
id: tag
run: |
tag="${{ github.event.inputs.version }}"
if [ -z "${tag}" ]; then
tag="${{ steps.semver.outputs.tag }}"
fi
echo "::set-output name=tag::${tag}"
- name: Package
run: ./scripts/package.sh --version "${{ steps.tag.outputs.tag }}"
- name: Create Release Notes
id: create-release-notes
uses: paketo-buildpacks/github-config/actions/release/notes@main
with:
repo: ${{ github.repository }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
- name: Create Release
uses: paketo-buildpacks/github-config/actions/release/create@main
with:
repo: ${{ github.repository }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
tag_name: v${{ steps.tag.outputs.tag }}
target_commitish: ${{ github.sha }}
name: v${{ steps.tag.outputs.tag }}
body: ${{ steps.create-release-notes.outputs.release_body }}
draft: true
assets: |
[
{
"path": "build/buildpack.tgz",
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz",
"content_type": "application/gzip"
},
{
"path": "build/buildpackage.cnb",
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb",
"content_type": "application/gzip"
}
]
17 changes: 17 additions & 0 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Auto-label PR
on:
pull_request:
branches:
- main

concurrency: pr_labels

jobs:
semver-label:
name: Semver Auto-Label
runs-on: ubuntu-latest
steps:
- name: Auto-label Semver
uses: paketo-buildpacks/github-config/actions/pull-request/auto-semver-label@main
env:
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@v2

- name: Checkout github-config
uses: actions/checkout@v2
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
Loading

0 comments on commit 1fa118c

Please sign in to comment.