Skip to content

Commit

Permalink
Merge branch 'main' into Issue#1561
Browse files Browse the repository at this point in the history
  • Loading branch information
natalieparellano committed May 19, 2023
2 parents 1c6ccff + 1aa6461 commit 86e4b7f
Show file tree
Hide file tree
Showing 188 changed files with 17,562 additions and 11,039 deletions.
17,530 changes: 10,768 additions & 6,762 deletions .github/workflows/actions/release-notes/dist/index.js

Large diffs are not rendered by default.

474 changes: 470 additions & 4 deletions .github/workflows/actions/release-notes/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/actions/release-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "ncc build action.js -o dist/"
},
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/core": "^1.10.0",
"@actions/github": "^4.0.0",
"@octokit/rest": "^18.0.0",
"yaml": "^1.10.0"
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: benchmark
on:
push:
branches:
- main

permissions:
contents: write
deployments: write

jobs:
benchmark:
name: Run Go benchmark example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Set up go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Run benchmark
run: |
mkdir out || (exit 0)
go test -bench=. -benchtime=1s ./benchmarks/... -tags=benchmarks | tee ./out/benchmark.txt
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Go Benchmark
tool: 'go'
output-file-path: ./out/benchmark.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@edithwuly'
21 changes: 10 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ jobs:
}
shell: powershell
- name: Set up go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.20"
- name: Set up go env for Unix
if: runner.os != 'Windows'
run: |
Expand Down Expand Up @@ -177,9 +177,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.20"
- name: Build
run: |
[[ $GITHUB_REF =~ ^refs\/heads\/release/(.*)$ ]] && version=${BASH_REMATCH[1]} || version=0.0.0
Expand Down Expand Up @@ -252,14 +252,13 @@ jobs:
echo "version=$LIFECYCLE_VERSION" >> $GITHUB_OUTPUT
- name: Extract pack help
id: pack_help
# Replacements have to do with multiline output.
# See https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/m-p/38372/highlight/true#M3322
# Multiline output use a syntax similar to heredocs.
# see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
run: |
PACK_HELP=$(./pack-linux/pack --help)
PACK_HELP="${PACK_HELP//'%'/'%25'}"
PACK_HELP="${PACK_HELP//$'\n'/'%0A'}"
PACK_HELP="${PACK_HELP//$'\r'/'%0D'}"
echo "help=$PACK_HELP" >> $GITHUB_OUTPUT
DELIMITER="$(uuidgen)"
echo "help<<${DELIMITER}" >> $GITHUB_OUTPUT
./pack-linux/pack --help >> $GITHUB_OUTPUT
echo "${DELIMITER}" >> $GITHUB_OUTPUT
- name: Generate changelog
uses: ./.github/workflows/actions/release-notes
id: changelog
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/check-latest-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Read go versions
Expand All @@ -31,11 +31,11 @@ jobs:
tar xzf out.tgz
LATEST_RELEASE_GO_VERSION=$(go version ./pack | cut -d ' ' -f 2)
echo "::set-output name=latest-go-version::${LATEST_GO_VERSION}"
echo "::set-output name=latest-release-go-version::${LATEST_RELEASE_GO_VERSION}"
echo "latest-go-version=${LATEST_GO_VERSION}" >> "$GITHUB_OUTPUT"
echo "latest-release-go-version=${LATEST_RELEASE_GO_VERSION}" >> "$GITHUB_OUTPUT"
LATEST_RELEASE_VERSION=$(echo $LATEST_RELEASE_VERSION | cut -d \v -f 2)
echo "::set-output name=latest-release-version::${LATEST_RELEASE_VERSION}"
echo "latest-release-version=${LATEST_RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
- name: Create issue if needed
if: ${{ steps.read-go.outputs.latest-go-version != steps.read-go.outputs.latest-release-go-version }}
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.20"
- name: Set up go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/delivery-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
default: false

env:
BUILDER: "paketobuildpacks/builder:tiny"
BUILDER: "paketobuildpacks/builder-jammy-tiny"
IMG_NAME: 'pack'
USERNAME: 'buildpacksio'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/delivery-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
UBUNTU_VERSION: ${{ matrix.target }}

###
# NOTE: 'uses' does not suport interpolation so we have to manually define the
# NOTE: 'uses' does not support interpolation so we have to manually define the
# following steps per variant.
###

Expand Down
131 changes: 82 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ TEST_TIMEOUT?=1200s
UNIT_TIMEOUT?=$(TEST_TIMEOUT)
NO_DOCKER?=

# Clean build flags
clean_build := $(strip ${PACK_BUILD})
clean_sha := $(strip ${PACK_GITSHA1})

# append build number and git sha to version, if not-empty
# Append build number and git sha to version, if not-empty
ifneq ($(and $(clean_build),$(clean_sha)),)
PACK_VERSION:=${PACK_VERSION}+git-${clean_sha}.build-${clean_build}
else ifneq ($(clean_build),)
Expand All @@ -50,53 +51,43 @@ export CGO_ENABLED=0

BINDIR:=/usr/bin/

.DEFAULT_GOAL := build

# this target must be listed first in order for it to be a default target,
# so that ubuntu_ppa's may be constructed using default build tools.
## build: Build the program
build: out
@echo "> Building..."
@echo "=====> Building..."
$(GOCMD) build -ldflags "-s -w -X 'github.com/buildpacks/pack.Version=${PACK_VERSION}' -extldflags ${LDFLAGS}" -trimpath -o ./out/$(PACK_BIN) -a ./cmd/pack

## all: Run clean, verify, test, and build operations
all: clean verify test build

# used by apt-get install when installing ubuntu ppa.
# move pack binary onto a path location.
install:
mkdir -p ${DESTDIR}${BINDIR}
cp ./out/$(PACK_BIN) ${DESTDIR}${BINDIR}/

mod-tidy:
$(GOCMD) mod tidy -compat=1.19
cd tools && $(GOCMD) mod tidy -compat=1.19

tidy: mod-tidy format

package: out
tar czf .$/out$/$(ARCHIVE_NAME).tgz -C .$/out$/ $(PACK_BIN)

install-mockgen:
@echo "> Installing mockgen..."
cd tools && $(GOCMD) install github.com/golang/mock/mockgen

install-goimports:
@echo "> Installing goimports..."
cd tools && $(GOCMD) install golang.org/x/tools/cmd/goimports
## clean: Clean the workspace
clean:
@echo "=====> Cleaning workspace..."
@$(RMRF) .$/out benchmarks.test || (exit 0)

## format: Format the code
format: install-goimports
@echo "> Formating code..."
@echo "=====> Formatting code..."
@goimports -l -w -local ${PACKAGE_BASE} ${SRC}
@go run tools/pedantic_imports/main.go ${PACKAGE_BASE} ${SRC}

install-golangci-lint:
@echo "> Installing golangci-lint..."
cd tools && $(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint
## generate: Generate mocks
generate: install-mockgen
@echo "=====> Generating mocks..."
$(GOCMD) generate ./...

## lint: Check the code
lint: install-golangci-lint
@echo "> Linting code..."
@echo "=====> Linting code..."
@golangci-lint run -c golangci.yaml

## test: Run unit and acceptance tests
test: unit acceptance

# append coverage arguments
## unit: Append coverage arguments
ifeq ($(TEST_COVERAGE), 1)
unit: GOTESTFLAGS:=$(GOTESTFLAGS) -coverprofile=./out/tests/coverage-unit.txt -covermode=atomic
endif
Expand All @@ -107,29 +98,18 @@ unit: out
@echo "> Running unit/integration tests..."
$(GOCMD) test $(GOTESTFLAGS) -timeout=$(UNIT_TIMEOUT) ./...

## acceptance: Run acceptance tests
acceptance: out
@echo "> Running acceptance tests..."
@echo "=====> Running acceptance tests..."
$(GOCMD) test $(GOTESTFLAGS) -timeout=$(ACCEPTANCE_TIMEOUT) -tags=acceptance ./acceptance

## acceptance-all: Run all acceptance tests
acceptance-all: export ACCEPTANCE_SUITE_CONFIG:=$(shell $(CAT) .$/acceptance$/testconfig$/all.json)
acceptance-all:
@echo "> Running acceptance tests..."
@echo "=====> Running acceptance tests..."
$(GOCMD) test $(GOTESTFLAGS) -timeout=$(ACCEPTANCE_TIMEOUT) -tags=acceptance ./acceptance

clean:
@echo "> Cleaning workspace..."
@$(RMRF) .$/out benchmarks.test || (exit 0)

verify: verify-format lint

generate: install-mockgen
@echo "> Generating mocks..."
$(GOCMD) generate ./...

verify-format: install-goimports
@echo "> Verifying format..."
$(if $(shell goimports -l -local ${PACKAGE_BASE} ${SRC}), @echo ERROR: Format verification failed! && goimports ${GOIMPORTS_DIFF_OPTION} -local ${PACKAGE_BASE} ${SRC} && exit 1)

## prepare-for-pr: Run clean, verify, and test operations and check for uncommitted changes
prepare-for-pr: tidy verify test
@git diff-index --quiet HEAD -- ||\
(echo "-----------------" &&\
Expand All @@ -141,18 +121,71 @@ prepare-for-pr: tidy verify test
echo "-----------------\n" &&\
exit 0)

## verify: Run format and lint checks
verify: verify-format lint

## verify-format: Verify the format
verify-format: install-goimports
@echo "=====> Verifying format..."
$(if $(shell goimports -l -local ${PACKAGE_BASE} ${SRC}), @echo ERROR: Format verification failed! && goimports ${GOIMPORTS_DIFF_OPTION} -local ${PACKAGE_BASE} ${SRC} && exit 1)

## benchmark: Run benchmark tests
benchmark: out
@echo "> Running Benchmarks"
@echo "=====> Running benchmarks"
$(GOCMD) test -run=^$ -bench=. -benchtime=1s -benchmem -memprofile=./out/bench_mem.out -cpuprofile=./out/bench_cpu.out -tags=benchmarks ./benchmarks/ -v
# NOTE: You can analyze the results, using go tool pprof. For instance, you can start a server to see a graph of the cpu usage by running
# go tool pprof -http=":8082" out/bench_cpu.out. Alternatively, you can run go tool pprof, and in the ensuing cli, run
# commands like top10 or web to dig down into the cpu and memory usage
# For more, see https://blog.golang.org/pprof

## package: Package the program
package: out
tar czf .$/out$/$(ARCHIVE_NAME).tgz -C .$/out$/ $(PACK_BIN)

## install: Install the program to the system
install:
mkdir -p ${DESTDIR}${BINDIR}
cp ./out/$(PACK_BIN) ${DESTDIR}${BINDIR}/

## install-mockgen: Used only by apt-get install when installing ubuntu ppa
install-mockgen:
@echo "=====> Installing mockgen..."
cd tools && $(GOCMD) install github.com/golang/mock/mockgen

## install-goimports: Install goimports dependency
install-goimports:
@echo "=====> Installing goimports..."
cd tools && $(GOCMD) install golang.org/x/tools/cmd/goimports

## install-golangci-lint: Install golangci-lint dependency
install-golangci-lint:
@echo "=====> Installing golangci-lint..."
cd tools && $(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint

## mod-tidy: Tidy Go modules
mod-tidy:
$(GOCMD) mod tidy -compat=1.20
cd tools && $(GOCMD) mod tidy -compat=1.20

## tidy: Tidy modules and format the code
tidy: mod-tidy format

# NOTE: Windows doesn't support `-p`
## out: Make a directory for output
out:
@mkdir out || (exit 0)
mkdir out$/tests || (exit 0)


.PHONY: clean build format imports lint test unit acceptance prepare-for-pr verify verify-format benchmark
## help: Display help information
help: Makefile
@echo ""
@echo "Usage:"
@echo ""
@echo " make [target]"
@echo ""
@echo "Targets:"
@echo ""
@awk -F ':|##' '/^[^\.%\t][^\t]*:.*##/{printf " \033[36m%-20s\033[0m %s\n", $$1, $$NF}' $(MAKEFILE_LIST) | sort
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'

.PHONY: clean build format imports lint test unit acceptance prepare-for-pr verify verify-format benchmark
Loading

0 comments on commit 86e4b7f

Please sign in to comment.