This repository has been archived by the owner on Sep 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of the dep-ensure buildpack (#4)
Signed-off-by: Ryan Moran <[email protected]> Signed-off-by: Arjun Sreedharan <[email protected]> Signed-off-by: Sophie Wigmore <[email protected]> Signed-off-by: Forest Eckhardt <[email protected]>
- Loading branch information
1 parent
bdcaced
commit bc2e13a
Showing
38 changed files
with
1,797 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: gomod | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
unit: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14 | ||
- 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@v1 | ||
with: | ||
go-version: 1.14 | ||
- 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 | ||
env: | ||
GIT_TOKEN: ${{ github.token }} | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
needs: integration | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true | ||
- name: Tag | ||
id: tag | ||
uses: paketo-buildpacks/github-config/actions/tag@master | ||
- name: Package | ||
run: PACKAGE_DIR=artifact ./scripts/package.sh --version "${{ steps.tag.outputs.tag }}" --archive | ||
- name: Create Release Notes | ||
id: create-release-notes | ||
run: | | ||
mkdir -p "${HOME}/bin" | ||
export PATH="${PATH}:${HOME}/bin" | ||
curl "https://github.com/paketo-buildpacks/packit/releases/download/v0.0.14/jam-linux" \ | ||
--silent \ | ||
--location \ | ||
--output "${HOME}/bin/jam" | ||
chmod +x "${HOME}/bin/jam" | ||
RELEASE_BODY=$(jam summarize --buildpack "${PWD}/artifact.tgz" --format markdown) | ||
# Coz of this messed up issue | ||
# https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/m-p/38372#M3322 | ||
RELEASE_BODY="${RELEASE_BODY//'%'/'%25'}" | ||
RELEASE_BODY="${RELEASE_BODY//$'\n'/'%0A'}" | ||
RELEASE_BODY="${RELEASE_BODY//$'\r'/'%0D'}" | ||
echo "::set-output name=release_body::$RELEASE_BODY" | ||
- name: Create Release | ||
uses: paketo-buildpacks/github-config/actions/release/create@master | ||
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: false | ||
assets: | | ||
[ | ||
{ | ||
"path": "artifact.tgz", | ||
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz", | ||
"content_type": "application/gzip" | ||
} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/[email protected] | ||
with: | ||
version: v1.27 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Sync | ||
|
||
on: | ||
repository_dispatch: | ||
types: working-dir-update | ||
|
||
jobs: | ||
build: | ||
name: Sync | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
# checkout paketo github-config as src-repo | ||
- name: Checkout paketo github-config repo | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: paketo-buildpacks/github-config | ||
path: config-repo | ||
|
||
# checkout this repo | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
path: current-repo | ||
|
||
- name: Run the sync action | ||
uses: paketo-buildpacks/github-config/actions/sync@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
with: | ||
config-repo: config-repo | ||
current-repo: current-repo | ||
config-path: "/implementation" | ||
ssh-private-key: ${{ secrets.PAKETO_BOT_SSH_KEY }} | ||
id: do-sync |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This workflow triggers on a published release event. | ||
# Requires the following secrets: | ||
# - LANGUAGE_FAMILY_REPO -> the full name of the repo to send the dispatch to (eg. paketo-buildpacks/nodejs) | ||
# - PAKETO_BOT_GITHUB_TOKEN -> a token with permissions to send the dispatch to the language family repo | ||
|
||
name: Send Dependency Update Dispatch | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
|
||
dispatch: | ||
runs-on: ubuntu-latest | ||
name: Send Dispatch | ||
steps: | ||
|
||
# Parses the release event JSON and fetches the details that make up a dependency update. | ||
# Dependency update details are provided as outputs. | ||
- name: Parse Release Dependency | ||
id: dependency | ||
uses: paketo-buildpacks/github-config/actions/dependency/parse@master | ||
|
||
# Generic repository dispatch sender. | ||
- name: Send Repository Dispatch | ||
uses: paketo-buildpacks/github-config/actions/dispatch@master | ||
with: | ||
repos: ${{ secrets.LANGUAGE_FAMILY_REPO }} | ||
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
event: dependency-update | ||
payload: | | ||
{ | ||
"strategy": "replace", | ||
"dependency": { | ||
"id": "${{ steps.dependency.outputs.id }}", | ||
"sha256": "${{ steps.dependency.outputs.sha256 }}", | ||
"source": "${{ steps.dependency.outputs.source }}", | ||
"source_sha256": "${{ steps.dependency.outputs.source_sha256 }}", | ||
"stacks": ${{ steps.dependency.outputs.stacks }}, | ||
"uri": "${{ steps.dependency.outputs.uri }}", | ||
"version": "${{ steps.dependency.outputs.version }}" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Test Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
unit: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14 | ||
- 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@v1 | ||
with: | ||
go-version: 1.14 | ||
- 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 | ||
env: | ||
GIT_TOKEN: ${{ github.token }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.bin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pull_request_rules: | ||
- name: Auto merge pull requests from github-actions bot | ||
conditions: | ||
- author=github-actions[bot] | ||
# TODO: Fill in these conditions when they are finalized | ||
# - status-success=Unit Tests | ||
# - status-success=Integration Tests | ||
actions: | ||
merge: | ||
strict: true | ||
method: rebase | ||
delete_head_branch: {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package depensure | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"time" | ||
|
||
"github.com/paketo-buildpacks/packit" | ||
"github.com/paketo-buildpacks/packit/chronos" | ||
) | ||
|
||
//go:generate faux --interface BuildProcess --output fakes/build_process.go | ||
type BuildProcess interface { | ||
Execute(workspace, goPath, gocachedir string) (err error) | ||
} | ||
|
||
func Build( | ||
buildProcess BuildProcess, | ||
logger LogEmitter, | ||
clock chronos.Clock, | ||
) packit.BuildFunc { | ||
|
||
return func(context packit.BuildContext) (packit.BuildResult, error) { | ||
logger.Title("%s %s", context.BuildpackInfo.Name, context.BuildpackInfo.Version) | ||
logger.Process("Executing build process") | ||
|
||
depcachedirLayer, err := context.Layers.Get("depcachedir", packit.CacheLayer) | ||
if err != nil { | ||
return packit.BuildResult{}, err | ||
} | ||
|
||
gopath, err := ioutil.TempDir("", "gopath") | ||
if err != nil { | ||
return packit.BuildResult{}, fmt.Errorf("failed to create GOPATH directory: %w", err) | ||
} | ||
|
||
duration, err := clock.Measure(func() error { | ||
return buildProcess.Execute(context.WorkingDir, gopath, depcachedirLayer.Path) | ||
}) | ||
|
||
if err != nil { | ||
return packit.BuildResult{}, err | ||
} | ||
|
||
err = os.RemoveAll(gopath) | ||
if err != nil { | ||
return packit.BuildResult{}, fmt.Errorf("failed to delete GOPATH directory: %w", err) | ||
} | ||
|
||
logger.Action("Completed in %s", duration.Round(time.Millisecond)) | ||
logger.Break() | ||
|
||
return packit.BuildResult{ | ||
Layers: []packit.Layer{depcachedirLayer}, | ||
}, nil | ||
} | ||
} |
Oops, something went wrong.