diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..ad7caf9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @paketo-buildpacks/java-maintainers \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2adccd4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: daily + ignore: + - dependency-name: github.com/onsi/gomega + labels: + - semver:patch + - type:dependency-upgrade diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..73f0613 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,42 @@ +- name: semver:major + description: A change requiring a major version bump + color: f9d0c4 +- name: semver:minor + description: A change requiring a minor version bump + color: f9d0c4 +- name: semver:patch + description: A change requiring a patch version bump + color: f9d0c4 +- name: type:bug + description: A general bug + color: e3d9fc +- name: type:dependency-upgrade + description: A dependency upgrade + color: e3d9fc +- name: type:documentation + description: A documentation update + color: e3d9fc +- name: type:enhancement + description: A general enhancement + color: e3d9fc +- name: type:question + description: A user question + color: e3d9fc +- name: type:task + description: A general task + color: e3d9fc +- name: type:informational + description: Provides information or notice to the community + color: e3d9fc +- name: type:poll + description: Request for feedback from the community + color: e3d9fc +- name: note:ideal-for-contribution + description: An issue that a contributor can help us with + color: 54f7a8 +- name: note:on-hold + description: We can't start working on this issue yet + color: 54f7a8 +- name: note:good-first-issue + description: A good first issue to get started with + color: 54f7a8 diff --git a/.github/pipeline-descriptor.yml b/.github/pipeline-descriptor.yml new file mode 100644 index 0000000..97af5e0 --- /dev/null +++ b/.github/pipeline-descriptor.yml @@ -0,0 +1,30 @@ +github: + username: ${{ secrets.JAVA_GITHUB_USERNAME }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + +codeowners: +- path: "*" + owner: "@paketo-buildpacks/java-maintainers" + +package: + repositories: ["docker.io/paketobuildpacks/pipeline-builder-stool-pigeon","gcr.io/paketo-buildpacks/pipeline-builder-stool-pigeon"] + register: true + registry_token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + +docker_credentials: + - registry: gcr.io + username: _json_key + password: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} + - registry: docker.io + username: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} + password: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }} + +dependencies: +- id: maven + uses: docker://ghcr.io/paketo-buildpacks/actions/maven-dependency:main + with: + uri: https://repo1.maven.org/maven2 + group_id: org.apache.maven + artifact_id: apache-maven + classifier: bin + packaging: tar.gz diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..b5c1d5b --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,32 @@ +template: $CHANGES +name-template: $RESOLVED_VERSION +tag-template: v$RESOLVED_VERSION +categories: + - title: ⭐️ Enhancements + labels: + - type:enhancement + - title: "\U0001F41E Bug Fixes" + labels: + - type:bug + - title: "\U0001F4D4 Documentation" + labels: + - type:documentation + - title: ⛏ Dependency Upgrades + labels: + - type:dependency-upgrade + - title: "\U0001F6A7 Tasks" + labels: + - type:task +exclude-labels: + - type:question +version-resolver: + major: + labels: + - semver:major + minor: + labels: + - semver:minor + patch: + labels: + - semver:patch + default: patch diff --git a/.github/workflows/pb-create-package.yml b/.github/workflows/pb-create-package.yml new file mode 100644 index 0000000..e0bfeea --- /dev/null +++ b/.github/workflows/pb-create-package.yml @@ -0,0 +1,253 @@ +name: Create Package +"on": + release: + types: + - published +jobs: + create-package: + name: Create Package + runs-on: + - ubuntu-latest + steps: + - name: Docker login gcr.io + if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} + uses: docker/login-action@v2 + with: + password: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} + registry: gcr.io + username: _json_key + - name: Docker login docker.io + if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} + uses: docker/login-action@v2 + with: + password: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }} + registry: docker.io + username: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install create-package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package@${PAKETO_LIBPAK_COMMIT:=latest} + env: + PAKETO_LIBPAK_COMMIT: ${{ vars.PAKETO_LIBPAK_COMMIT }} + - name: Install crane + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing crane ${CRANE_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --show-error \ + --silent \ + --location \ + "https://github.com/google/go-containerregistry/releases/download/v${CRANE_VERSION}/go-containerregistry_Linux_x86_64.tar.gz" \ + | tar -C "${HOME}/bin" -xz crane + env: + CRANE_VERSION: 0.8.0 + - name: Install pack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing pack ${PACK_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --location \ + --show-error \ + --silent \ + "https://github.com/buildpacks/pack/releases/download/v${PACK_VERSION}/pack-v${PACK_VERSION}-linux.tgz" \ + | tar -C "${HOME}"/bin -xz pack + env: + PACK_VERSION: 0.30.0-pre2 + - name: Enable pack Experimental + if: ${{ false }} + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Enabling pack experimental features" + + mkdir -p "${HOME}"/.pack + echo "experimental = true" >> "${HOME}"/.pack/config.toml + - uses: actions/checkout@v3 + - if: ${{ false }} + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }} + path: |- + ${{ env.HOME }}/.pack + ${{ env.HOME }}/carton-cache + restore-keys: ${{ runner.os }}-go- + - name: Compute Version + id: version + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [ -z "${GITHUB_REF+set}" ]; then + echo "GITHUB_REF set to [${GITHUB_REF-}], but should never be empty or unset" + exit 255 + fi + + if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then + VERSION=${BASH_REMATCH[1]} + + MAJOR_VERSION="$(echo "${VERSION}" | awk -F '.' '{print $1 }')" + MINOR_VERSION="$(echo "${VERSION}" | awk -F '.' '{print $1 "." $2 }')" + + echo "version-major=${MAJOR_VERSION}" >> "$GITHUB_OUTPUT" + echo "version-minor=${MINOR_VERSION}" >> "$GITHUB_OUTPUT" + elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then + VERSION=${BASH_REMATCH[1]} + else + VERSION=$(git rev-parse --short HEAD) + fi + + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "Selected ${VERSION} from + * ref: ${GITHUB_REF} + * sha: ${GITHUB_SHA} + " + - name: Create Package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + # With Go 1.20, we need to set this so that we produce statically compiled binaries + # + # Starting with Go 1.20, Go will produce binaries that are dynamically linked against libc + # which can cause compatibility issues. The compiler links against libc on the build system + # but that may be newer than on the stacks we support. + export CGO_ENABLED=0 + + if [[ "${EXTENSION:-x}" == "true" ]]; then + export PACK_MODULE_TYPE=extension + else + export PACK_MODULE_TYPE=buildpack + fi + + if [[ "${INCLUDE_DEPENDENCIES}" == "true" ]]; then + create-package \ + --source ${SOURCE_PATH:-.} \ + --cache-location "${HOME}"/carton-cache \ + --destination "${HOME}"/${PACK_MODULE_TYPE} \ + --include-dependencies \ + --version "${VERSION}" + else + create-package \ + --source ${SOURCE_PATH:-.} \ + --destination "${HOME}"/${PACK_MODULE_TYPE} \ + --version "${VERSION}" + fi + + PACKAGE_FILE=${SOURCE_PATH:-.}/package.toml + [[ -e ${PACKAGE_FILE} ]] && cp ${PACKAGE_FILE} "${HOME}"/package.toml + printf '['${PACK_MODULE_TYPE}']\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/${PACK_MODULE_TYPE} "${OS}" >> "${HOME}"/package.toml + env: + EXTENSION: "true" + INCLUDE_DEPENDENCIES: "false" + OS: linux + SOURCE_PATH: "" + VERSION: ${{ steps.version.outputs.version }} + - name: Package Buildpack/Extension + id: package + run: |- + #!/usr/bin/env bash + + set -euo pipefail + + PACKAGE_LIST=($PACKAGES) + # Extract first repo (Docker Hub) as the main to package & register + PACKAGE=${PACKAGE_LIST[0]} + + if [[ "${EXTENSION:-x}" == "true" ]]; then + export PACK_MODULE_TYPE=extension + else + export PACK_MODULE_TYPE=buildpack + fi + + if [[ "${PUBLISH:-x}" == "true" ]]; then + pack ${PACK_MODULE_TYPE} package \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --publish + + if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then + crane tag "${PACKAGE}:${VERSION}" "${VERSION_MINOR}" + crane tag "${PACKAGE}:${VERSION}" "${VERSION_MAJOR}" + fi + crane tag "${PACKAGE}:${VERSION}" latest + echo "digest=$(crane digest "${PACKAGE}:${VERSION}")" >> "$GITHUB_OUTPUT" + + # copy to other repositories specified + for P in "${PACKAGE_LIST[@]}" + do + if [ "$P" != "$PACKAGE" ]; then + crane copy "${PACKAGE}:${VERSION}" "${P}:${VERSION}" + if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then + crane tag "${P}:${VERSION}" "${VERSION_MINOR}" + crane tag "${P}:${VERSION}" "${VERSION_MAJOR}" + fi + crane tag "${P}:${VERSION}" latest + fi + done + + else + pack ${PACK_MODULE_TYPE} package \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --format "${FORMAT}" + fi + env: + EXTENSION: "true" + PACKAGES: docker.io/paketobuildpacks/pipeline-builder-stool-pigeon gcr.io/paketo-buildpacks/pipeline-builder-stool-pigeon + PUBLISH: "true" + VERSION: ${{ steps.version.outputs.version }} + VERSION_MAJOR: ${{ steps.version.outputs.version-major }} + VERSION_MINOR: ${{ steps.version.outputs.version-minor }} + - name: Update release with digest + run: | + #!/usr/bin/env bash + + set -euo pipefail + + PAYLOAD=$(cat "${GITHUB_EVENT_PATH}") + + RELEASE_ID=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.id') + RELEASE_TAG_NAME=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.tag_name') + RELEASE_NAME=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.name') + RELEASE_BODY=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.release.body') + + gh api \ + --method PATCH \ + "/repos/:owner/:repo/releases/${RELEASE_ID}" \ + --field "tag_name=${RELEASE_TAG_NAME}" \ + --field "name=${RELEASE_NAME}" \ + --field "body=${RELEASE_BODY///\`${DIGEST}\`}" + env: + DIGEST: ${{ steps.package.outputs.digest }} + GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + - if: ${{ true }} + uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:4.0.1 + with: + address: docker.io/paketobuildpacks/pipeline-builder-stool-pigeon@${{ steps.package.outputs.digest }} + id: paketo-buildpacks/pipeline-builder-stool-pigeon + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + version: ${{ steps.version.outputs.version }} diff --git a/.github/workflows/pb-minimal-labels.yml b/.github/workflows/pb-minimal-labels.yml new file mode 100644 index 0000000..75ea2ac --- /dev/null +++ b/.github/workflows/pb-minimal-labels.yml @@ -0,0 +1,29 @@ +name: Minimal Labels +"on": + pull_request: + types: + - synchronize + - reopened + - labeled + - unlabeled +jobs: + semver: + name: Minimal Semver Labels + runs-on: + - ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v4 + with: + count: 1 + labels: semver:major, semver:minor, semver:patch + mode: exactly + type: + name: Minimal Type Labels + runs-on: + - ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v4 + with: + count: 1 + labels: type:bug, type:dependency-upgrade, type:documentation, type:enhancement, type:question, type:task + mode: exactly diff --git a/.github/workflows/pb-synchronize-labels.yml b/.github/workflows/pb-synchronize-labels.yml new file mode 100644 index 0000000..8f93206 --- /dev/null +++ b/.github/workflows/pb-synchronize-labels.yml @@ -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: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-tests.yml b/.github/workflows/pb-tests.yml new file mode 100644 index 0000000..9e4255c --- /dev/null +++ b/.github/workflows/pb-tests.yml @@ -0,0 +1,234 @@ +name: Tests +"on": + merge_group: + types: + - checks_requested + branches: + - main + pull_request: {} + push: + branches: + - main +jobs: + create-package: + name: Create Package Test + runs-on: + - ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install create-package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package@${PAKETO_LIBPAK_COMMIT:=latest} + env: + PAKETO_LIBPAK_COMMIT: ${{ vars.PAKETO_LIBPAK_COMMIT }} + - name: Install pack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing pack ${PACK_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --location \ + --show-error \ + --silent \ + "https://github.com/buildpacks/pack/releases/download/v${PACK_VERSION}/pack-v${PACK_VERSION}-linux.tgz" \ + | tar -C "${HOME}"/bin -xz pack + env: + PACK_VERSION: 0.30.0-pre2 + - name: Enable pack Experimental + if: ${{ false }} + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Enabling pack experimental features" + + mkdir -p "${HOME}"/.pack + echo "experimental = true" >> "${HOME}"/.pack/config.toml + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/extension.toml', '**/package.toml') }} + path: |- + ${{ env.HOME }}/.pack + ${{ env.HOME }}/carton-cache + restore-keys: ${{ runner.os }}-go- + - name: Compute Version + id: version + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [ -z "${GITHUB_REF+set}" ]; then + echo "GITHUB_REF set to [${GITHUB_REF-}], but should never be empty or unset" + exit 255 + fi + + if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then + VERSION=${BASH_REMATCH[1]} + + MAJOR_VERSION="$(echo "${VERSION}" | awk -F '.' '{print $1 }')" + MINOR_VERSION="$(echo "${VERSION}" | awk -F '.' '{print $1 "." $2 }')" + + echo "version-major=${MAJOR_VERSION}" >> "$GITHUB_OUTPUT" + echo "version-minor=${MINOR_VERSION}" >> "$GITHUB_OUTPUT" + elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then + VERSION=${BASH_REMATCH[1]} + else + VERSION=$(git rev-parse --short HEAD) + fi + + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "Selected ${VERSION} from + * ref: ${GITHUB_REF} + * sha: ${GITHUB_SHA} + " + - name: Create Package + run: | + #!/usr/bin/env bash + + set -euo pipefail + + # With Go 1.20, we need to set this so that we produce statically compiled binaries + # + # Starting with Go 1.20, Go will produce binaries that are dynamically linked against libc + # which can cause compatibility issues. The compiler links against libc on the build system + # but that may be newer than on the stacks we support. + export CGO_ENABLED=0 + + if [[ "${EXTENSION:-x}" == "true" ]]; then + export PACK_MODULE_TYPE=extension + else + export PACK_MODULE_TYPE=buildpack + fi + + if [[ "${INCLUDE_DEPENDENCIES}" == "true" ]]; then + create-package \ + --source ${SOURCE_PATH:-.} \ + --cache-location "${HOME}"/carton-cache \ + --destination "${HOME}"/${PACK_MODULE_TYPE} \ + --include-dependencies \ + --version "${VERSION}" + else + create-package \ + --source ${SOURCE_PATH:-.} \ + --destination "${HOME}"/${PACK_MODULE_TYPE} \ + --version "${VERSION}" + fi + + PACKAGE_FILE=${SOURCE_PATH:-.}/package.toml + [[ -e ${PACKAGE_FILE} ]] && cp ${PACKAGE_FILE} "${HOME}"/package.toml + printf '['${PACK_MODULE_TYPE}']\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/${PACK_MODULE_TYPE} "${OS}" >> "${HOME}"/package.toml + env: + EXTENSION: "true" + INCLUDE_DEPENDENCIES: "true" + OS: linux + VERSION: ${{ steps.version.outputs.version }} + - name: Package Buildpack / Extension + run: |- + #!/usr/bin/env bash + + set -euo pipefail + + PACKAGE_LIST=($PACKAGES) + # Extract first repo (Docker Hub) as the main to package & register + PACKAGE=${PACKAGE_LIST[0]} + + if [[ "${EXTENSION:-x}" == "true" ]]; then + export PACK_MODULE_TYPE=extension + else + export PACK_MODULE_TYPE=buildpack + fi + + if [[ "${PUBLISH:-x}" == "true" ]]; then + pack ${PACK_MODULE_TYPE} package \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --publish + + if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then + crane tag "${PACKAGE}:${VERSION}" "${VERSION_MINOR}" + crane tag "${PACKAGE}:${VERSION}" "${VERSION_MAJOR}" + fi + crane tag "${PACKAGE}:${VERSION}" latest + echo "digest=$(crane digest "${PACKAGE}:${VERSION}")" >> "$GITHUB_OUTPUT" + + # copy to other repositories specified + for P in "${PACKAGE_LIST[@]}" + do + if [ "$P" != "$PACKAGE" ]; then + crane copy "${PACKAGE}:${VERSION}" "${P}:${VERSION}" + if [[ -n ${VERSION_MINOR:-} && -n ${VERSION_MAJOR:-} ]]; then + crane tag "${P}:${VERSION}" "${VERSION_MINOR}" + crane tag "${P}:${VERSION}" "${VERSION_MAJOR}" + fi + crane tag "${P}:${VERSION}" latest + fi + done + + else + pack ${PACK_MODULE_TYPE} package \ + "${PACKAGE}:${VERSION}" \ + --config "${HOME}"/package.toml \ + --format "${FORMAT}" + fi + env: + EXTENSION: "true" + FORMAT: image + PACKAGES: test + VERSION: ${{ steps.version.outputs.version }} + unit: + name: Unit Test + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + path: ${{ env.HOME }}/go/pkg/mod + restore-keys: ${{ runner.os }}-go- + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install richgo + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing richgo ${RICHGO_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --location \ + --show-error \ + --silent \ + "https://github.com/kyoh86/richgo/releases/download/v${RICHGO_VERSION}/richgo_${RICHGO_VERSION}_linux_amd64.tar.gz" \ + | tar -C "${HOME}"/bin -xz richgo + env: + RICHGO_VERSION: 0.3.10 + - name: Run Tests + run: | + #!/usr/bin/env bash + + set -euo pipefail + + richgo test ./... + env: + RICHGO_FORCE_COLOR: "1" diff --git a/.github/workflows/pb-update-draft-release.yml b/.github/workflows/pb-update-draft-release.yml new file mode 100644 index 0000000..28a9754 --- /dev/null +++ b/.github/workflows/pb-update-draft-release.yml @@ -0,0 +1,15 @@ +name: Update Draft Release +"on": + push: + branches: + - main +jobs: + update: + name: Update Draft Release + runs-on: + - ubuntu-latest + steps: + - id: release-drafter + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-go.yml b/.github/workflows/pb-update-go.yml new file mode 100644 index 0000000..90f6d47 --- /dev/null +++ b/.github/workflows/pb-update-go.yml @@ -0,0 +1,72 @@ +name: Update Go +"on": + schedule: + - cron: 13 2 * * 1 + workflow_dispatch: {} +jobs: + update: + name: Update Go + runs-on: + - ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - uses: actions/checkout@v3 + - name: Update Go Version & Modules + id: update-go + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [ -z "${GO_VERSION:-}" ]; then + echo "No go version set" + exit 1 + fi + + OLD_GO_VERSION=$(grep -P '^go \d\.\d+' go.mod | cut -d ' ' -f 2) + + go mod edit -go="$GO_VERSION" + go mod tidy + go get -u -t ./... + go mod tidy + + git add go.mod go.sum + git checkout -- . + + if [ "$OLD_GO_VERSION" == "$GO_VERSION" ]; then + COMMIT_TITLE="Bump Go Modules" + COMMIT_BODY="Bumps Go modules used by the project. See the commit for details on what modules were updated." + COMMIT_SEMVER="semver:patch" + else + COMMIT_TITLE="Bump Go from ${OLD_GO_VERSION} to ${GO_VERSION}" + COMMIT_BODY="Bumps Go from ${OLD_GO_VERSION} to ${GO_VERSION} and update Go modules used by the project. See the commit for details on what modules were updated." + COMMIT_SEMVER="semver:minor" + fi + + echo "commit-title=${COMMIT_TITLE}" >> "$GITHUB_OUTPUT" + echo "commit-body=${COMMIT_BODY}" >> "$GITHUB_OUTPUT" + echo "commit-semver=${COMMIT_SEMVER}" >> "$GITHUB_OUTPUT" + env: + GO_VERSION: "1.20" + - uses: peter-evans/create-pull-request@v5 + with: + author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com> + body: |- + ${{ steps.update-go.outputs.commit-body }} + +
+ Release Notes + ${{ steps.pipeline.outputs.release-notes }} +
+ branch: update/go + commit-message: |- + ${{ steps.update-go.outputs.commit-title }} + + ${{ steps.update-go.outputs.commit-body }} + delete-branch: true + labels: ${{ steps.update-go.outputs.commit-semver }}, type:task + signoff: true + title: ${{ steps.update-go.outputs.commit-title }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-maven.yml b/.github/workflows/pb-update-maven.yml new file mode 100644 index 0000000..f3d1ad9 --- /dev/null +++ b/.github/workflows/pb-update-maven.yml @@ -0,0 +1,123 @@ +name: Update maven +"on": + schedule: + - cron: 0 5 * * 1-5 + workflow_dispatch: {} +jobs: + update: + name: Update Build Module Dependency + runs-on: + - ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install update-buildmodule-dependency + run: | + #!/usr/bin/env bash + + set -euo pipefail + + go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/update-buildmodule-dependency@${PAKETO_LIBPAK_COMMIT:=latest} + env: + PAKETO_LIBPAK_COMMIT: ${{ vars.PAKETO_LIBPAK_COMMIT }} + - name: Install yj + run: | + #!/usr/bin/env bash + + set -euo pipefail + + echo "Installing yj ${YJ_VERSION}" + + mkdir -p "${HOME}"/bin + echo "${HOME}/bin" >> "${GITHUB_PATH}" + + curl \ + --location \ + --show-error \ + --silent \ + --output "${HOME}"/bin/yj \ + "https://github.com/sclevine/yj/releases/download/v${YJ_VERSION}/yj-linux" + + chmod +x "${HOME}"/bin/yj + env: + YJ_VERSION: 5.0.0 + - uses: actions/checkout@v3 + - id: dependency + uses: docker://ghcr.io/paketo-buildpacks/actions/maven-dependency:main + with: + artifact_id: apache-maven + classifier: bin + group_id: org.apache.maven + packaging: tar.gz + uri: https://repo1.maven.org/maven2 + - name: Update BuildModule Dependency + id: buildmodule + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ "${EXTENSION:-x}" == "true" ]]; then + export PACK_MODULE_TYPE=extension + else + export PACK_MODULE_TYPE=buildpack + fi + + OLD_VERSION=$(yj -tj < ${PACK_MODULE_TYPE}.toml | jq -r " + .metadata.dependencies[] | + select( .id == env.ID ) | + select( .version | test( env.VERSION_PATTERN ) ) | + .version") + + update-buildmodule-dependency \ + --buildmodule-toml ${PACK_MODULE_TYPE}.toml \ + --id "${ID}" \ + --version-pattern "${VERSION_PATTERN}" \ + --version "${VERSION}" \ + --cpe-pattern "${CPE_PATTERN:-}" \ + --cpe "${CPE:-}" \ + --purl-pattern "${PURL_PATTERN:-}" \ + --purl "${PURL:-}" \ + --uri "${URI}" \ + --sha256 "${SHA256}" + + git add ${PACK_MODULE_TYPE}.toml + git checkout -- . + + if [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $1}')" != "$(echo "$VERSION" | awk -F '.' '{print $1}')" ]; then + LABEL="semver:major" + elif [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $2}')" != "$(echo "$VERSION" | awk -F '.' '{print $2}')" ]; then + LABEL="semver:minor" + else + LABEL="semver:patch" + fi + + echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT" + echo "new-version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "version-label=${LABEL}" >> "$GITHUB_OUTPUT" + env: + CPE: ${{ steps.dependency.outputs.cpe }} + CPE_PATTERN: "" + EXTENSION: "true" + ID: maven + PURL: ${{ steps.dependency.outputs.purl }} + PURL_PATTERN: "" + SHA256: ${{ steps.dependency.outputs.sha256 }} + URI: ${{ steps.dependency.outputs.uri }} + VERSION: ${{ steps.dependency.outputs.version }} + VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+' + - uses: peter-evans/create-pull-request@v5 + with: + author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com> + body: Bumps `maven` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildmodule.outputs.new-version }}`. + branch: update/buildmodule/maven + commit-message: |- + Bump maven from ${{ steps.buildmodule.outputs.old-version }} to ${{ steps.buildmodule.outputs.new-version }} + + Bumps maven from ${{ steps.buildmodule.outputs.old-version }} to ${{ steps.buildmodule.outputs.new-version }}. + delete-branch: true + labels: ${{ steps.buildmodule.outputs.version-label }}, type:dependency-upgrade + signoff: true + title: Bump maven from ${{ steps.buildmodule.outputs.old-version }} to ${{ steps.buildmodule.outputs.new-version }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-pipeline.yml b/.github/workflows/pb-update-pipeline.yml new file mode 100644 index 0000000..4bc5c80 --- /dev/null +++ b/.github/workflows/pb-update-pipeline.yml @@ -0,0 +1,89 @@ +name: Update Pipeline +"on": + push: + branches: + - main + paths: + - .github/pipeline-descriptor.yml + schedule: + - cron: 0 5 * * 1-5 + workflow_dispatch: {} +jobs: + update: + name: Update Pipeline + runs-on: + - ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install octo + run: | + #!/usr/bin/env bash + + set -euo pipefail + + go install -ldflags="-s -w" github.com/paketo-buildpacks/pipeline-builder/cmd/octo@${PAKETO_PIPELINEBUILDER_COMMIT:=latest} + env: + PAKETO_PIPELINEBUILDER_COMMIT: ${{ vars.PAKETO_PIPELINEBUILDER_COMMIT }} + - uses: actions/checkout@v3 + - name: Update Pipeline + id: pipeline + run: | + #!/usr/bin/env bash + + set -euo pipefail + + if [[ -f .github/pipeline-version ]]; then + OLD_VERSION=$(cat .github/pipeline-version) + else + OLD_VERSION="0.0.0" + fi + + rm .github/workflows/pb-*.yml || true + octo --descriptor "${DESCRIPTOR}" + + PAYLOAD=$(gh api /repos/paketo-buildpacks/pipeline-builder/releases/latest) + + NEW_VERSION=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.name') + echo "${NEW_VERSION}" > .github/pipeline-version + + RELEASE_NOTES=$( + gh api \ + -F text="$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.body')" \ + -F mode="gfm" \ + -F context="paketo-buildpacks/pipeline-builder" \ + -X POST /markdown + ) + + git add .github/ + git checkout -- . + + echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT" + echo "new-version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" + + DELIMITER=$(openssl rand -hex 16) # roughly the same entropy as uuid v4 used in https://github.com/actions/toolkit/blob/b36e70495fbee083eb20f600eafa9091d832577d/packages/core/src/file-command.ts#L28 + printf "release-notes<<%s\n%s\n%s\n" "${DELIMITER}" "${RELEASE_NOTES}" "${DELIMITER}" >> "${GITHUB_OUTPUT}" # see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings + env: + DESCRIPTOR: .github/pipeline-descriptor.yml + GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + - uses: peter-evans/create-pull-request@v5 + with: + author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com> + body: |- + Bumps pipeline from `${{ steps.pipeline.outputs.old-version }}` to `${{ steps.pipeline.outputs.new-version }}`. + +
+ Release Notes + ${{ steps.pipeline.outputs.release-notes }} +
+ branch: update/pipeline + commit-message: |- + Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }} + + Bumps pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}. + delete-branch: true + labels: semver:patch, type:task + signoff: true + title: Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b87e0bf --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Copyright 2023 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bin/ +dependencies/ +package/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..62589ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..9fda69f --- /dev/null +++ b/NOTICE @@ -0,0 +1,10 @@ +pipeline-builder-stool-pigeon + +Copyright (c) 2023-Present CloudFoundry.org Foundation, Inc. All Rights Reserved. + +This project is licensed to you under the Apache License, Version 2.0 (the "License"). +You may not use this project except in compliance with the License. + +This project may include a number of subcomponents with separate copyright notices +and license terms. Your use of these subcomponents is subject to the terms and +conditions of the subcomponent's license, as noted in the LICENSE file. diff --git a/README.md b/README.md index 830f950..42cf13a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# pipeline-builder-stool-pigeon -A no-op Cloud-Native Buildpacks extension that is used for validating changes to pipeline-builder generated Github actions +# `gcr.io/paketo-buildpacks/pipeline-builder-stool-pigeon` + +The Paketo Image Extension for Pipeline Builder Stool Pigeon is a Cloud Native Buildpack Image Extension that does nothing. It's primary purpose is to function as a validation for changes being made to the pipeline-builder. + +## Behavior + +This extension will participate all the following conditions are met + +* always + +The extension will do the following: + +* nothing + +## License + +This extension is released under version 2.0 of the [Apache License][a]. + +[a]: http://www.apache.org/licenses/LICENSE-2.0 + diff --git a/cmd/main/main.go b/cmd/main/main.go new file mode 100644 index 0000000..214e829 --- /dev/null +++ b/cmd/main/main.go @@ -0,0 +1,32 @@ +/* + * Copyright 2018-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "os" + + "github.com/paketo-buildpacks/libpak" + "github.com/paketo-buildpacks/libpak/bard" + "github.com/paketo-buildpacks/pipeline-builder-stool-pigeon/stoolpigeon" +) + +func main() { + libpak.ExtensionMain( + stoolpigeon.Detect{}.Detect, + stoolpigeon.Generator{Logger: bard.NewLogger(os.Stdout)}.Generate, + ) +} diff --git a/extension.toml b/extension.toml new file mode 100644 index 0000000..35ae5bd --- /dev/null +++ b/extension.toml @@ -0,0 +1,54 @@ +# Copyright 2023 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +api = "0.8" + +[extension] + description = "A Cloud Native Buildpacks Image Extension that provides/does nothing. For testing only." + homepage = "https://github.com/paketo-buildpacks/pipeline-builder-stool-pigeon" + id = "paketo-buildpacks/pipeline-builder-stool-pigeon" + keywords = ["nothing"] + name = "Paketo Image Extension for Pipeline Builder Stool Pigeon" + version = "{{.version}}" + + [[extension.licenses]] + type = "Apache-2.0" + uri = "https://github.com/paketo-buildpacks/pipeline-builder-stool-pigeon/blob/main/LICENSE" + +[metadata] + include-files = ["LICENSE", "NOTICE", "README.md", "bin/generate", "bin/detect", "bin/main", "extension.toml"] + pre-package = "scripts/build.sh" + + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:apache:maven:3.9.3:*:*:*:*:*:*:*"] + id = "maven" + name = "Apache Maven" + purl = "pkg:generic/apache-maven@3.9.3" + sha256 = "e1e13ac0c42f3b64d900c57ffc652ecef682b8255d7d354efbbb4f62519da4f1" + stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"] + uri = "https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.tar.gz" + version = "3.9.3" + + [[metadata.dependencies.licenses]] + type = "Apache-2.0" + uri = "https://www.apache.org/licenses/" + +[[stacks]] + id = "io.buildpacks.stacks.bionic" + +[[stacks]] + id = "io.paketo.stacks.tiny" + +[[stacks]] + id = "*" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..48d53d0 --- /dev/null +++ b/go.mod @@ -0,0 +1,32 @@ +module github.com/paketo-buildpacks/pipeline-builder-stool-pigeon + +go 1.20 + +replace github.com/buildpacks/libcnb => github.com/buildpacks/libcnb v1.24.1-0.20230627130937-5d3d3f6e6d16 + +replace github.com/paketo-buildpacks/libpak => github.com/paketo-buildpacks/libpak v1.66.1-0.20230707152440-cd6875914a49 + +require ( + github.com/buildpacks/libcnb v1.24.1-0.20230627130937-5d3d3f6e6d16 + github.com/onsi/gomega v1.27.8 + github.com/paketo-buildpacks/libpak v1.66.1-0.20230627140602-0d0509ad1545 + github.com/sclevine/spec v1.4.0 +) + +require ( + github.com/BurntSushi/toml v1.3.2 // indirect + github.com/Masterminds/semver v1.5.0 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/creack/pty v1.1.18 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/heroku/color v0.0.6 // indirect + github.com/imdario/mergo v0.3.16 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..b9fd7ba --- /dev/null +++ b/go.sum @@ -0,0 +1,60 @@ +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/CycloneDX/cyclonedx-go v0.7.1 h1:5w1SxjGm9MTMNTuRbEPyw21ObdbaagTWF/KfF0qHTRE= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/buildpacks/libcnb v1.24.1-0.20230627130937-5d3d3f6e6d16 h1:rx4pWmx2K/BnT0K41xX0BCGCvnQFLMGza7MTD474EwE= +github.com/buildpacks/libcnb v1.24.1-0.20230627130937-5d3d3f6e6d16/go.mod h1:SALIsTZ/aKTjVImBl20gf4QaZV6UQNV4WX2I4a6Am4A= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= +github.com/heroku/color v0.0.6 h1:UTFFMrmMLFcL3OweqP1lAdp8i1y/9oHqkeHjQ/b/Ny0= +github.com/heroku/color v0.0.6/go.mod h1:ZBvOcx7cTF2QKOv4LbmoBtNl5uB17qWxGuzZrsi1wLU= +github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= +github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= +github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss= +github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= +github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ= +github.com/paketo-buildpacks/libpak v1.66.1-0.20230707152440-cd6875914a49 h1:t/1JPeLKsBkGCfE09MU3s2Er018NorSuxhBI1Y1IrYE= +github.com/paketo-buildpacks/libpak v1.66.1-0.20230707152440-cd6875914a49/go.mod h1:NQIzZJXFMp8MxVjBjWl6htjCMTcC3oirC4r3NOLQmew= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= +github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..be987a3 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euo pipefail + +GOOS="linux" go build -ldflags='-s -w' -o bin/main github.com/paketo-buildpacks/pipeline-builder-stool-pigeon/cmd/main + +if [ "${STRIP:-false}" != "false" ]; then + strip bin/main +fi + +if [ "${COMPRESS:-none}" != "none" ]; then + $COMPRESS bin/main +fi + +ln -fs main bin/generate +ln -fs main bin/detect diff --git a/stoolpigeon/detect.go b/stoolpigeon/detect.go new file mode 100644 index 0000000..bea83f9 --- /dev/null +++ b/stoolpigeon/detect.go @@ -0,0 +1,37 @@ +/* + * Copyright 2018-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package stoolpigeon + +import "github.com/buildpacks/libcnb" + +type Detect struct{} + +func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) { + return libcnb.DetectResult{ + Pass: true, + Plans: []libcnb.BuildPlan{ + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "stoolpigeon"}, + }, + Requires: []libcnb.BuildPlanRequire{ + {Name: "stoolpigeon"}, + }, + }, + }, + }, nil +} diff --git a/stoolpigeon/detect_test.go b/stoolpigeon/detect_test.go new file mode 100644 index 0000000..79381b5 --- /dev/null +++ b/stoolpigeon/detect_test.go @@ -0,0 +1,62 @@ +/* + * Copyright 2018-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package stoolpigeon_test + +import ( + "os" + "testing" + + "github.com/buildpacks/libcnb" + . "github.com/onsi/gomega" + "github.com/paketo-buildpacks/pipeline-builder-stool-pigeon/stoolpigeon" + "github.com/sclevine/spec" +) + +func testDetect(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + + ctx libcnb.DetectContext + detect stoolpigeon.Detect + ) + + it.Before(func() { + var err error + ctx.ApplicationPath, err = os.MkdirTemp("", "stoolpigeon") + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + Expect(os.RemoveAll(ctx.ApplicationPath)).To(Succeed()) + }) + + it("passes always", func() { + Expect(detect.Detect(ctx)).To(Equal(libcnb.DetectResult{ + Pass: true, + Plans: []libcnb.BuildPlan{ + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "stoolpigeon"}, + }, + Requires: []libcnb.BuildPlanRequire{ + {Name: "stoolpigeon"}, + }, + }, + }, + })) + }) +} diff --git a/stoolpigeon/generate.go b/stoolpigeon/generate.go new file mode 100644 index 0000000..a0f23dd --- /dev/null +++ b/stoolpigeon/generate.go @@ -0,0 +1,46 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package stoolpigeon + +import ( + "fmt" + "os" + + "github.com/buildpacks/libcnb" + "github.com/buildpacks/libcnb/log" +) + +type Generator struct { + Logger log.Logger +} + +func (Generator) Generate(context libcnb.GenerateContext) (libcnb.GenerateResult, error) { + // here you can read the context.ApplicationPath folder + // and create run.Dockerfile and build.Dockerfile in the context.OutputPath folder + // and read metadata from the context.Extension struct + + // Just to use context to keep compiler happy =) + fmt.Println(context.Extension.Info.ID) + + result := libcnb.NewGenerateResult() + return result, nil +} + +func ExampleGenerate() { + generator := Generator{log.New(os.Stdout)} + libcnb.ExtensionMain(nil, generator.Generate) +} diff --git a/stoolpigeon/generate_test.go b/stoolpigeon/generate_test.go new file mode 100644 index 0000000..a5a1c35 --- /dev/null +++ b/stoolpigeon/generate_test.go @@ -0,0 +1,50 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package stoolpigeon_test + +import ( + "os" + "testing" + + "github.com/buildpacks/libcnb" + . "github.com/onsi/gomega" + "github.com/paketo-buildpacks/pipeline-builder-stool-pigeon/stoolpigeon" + "github.com/sclevine/spec" +) + +func testGenerate(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + + ctx libcnb.GenerateContext + generate stoolpigeon.Generator + ) + + it.Before(func() { + var err error + ctx.ApplicationPath, err = os.MkdirTemp("", "stoolpigeon") + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + Expect(os.RemoveAll(ctx.ApplicationPath)).To(Succeed()) + }) + + it("passes always", func() { + Expect(generate.Generate(ctx)).To(Equal(libcnb.GenerateResult{})) + }) +} diff --git a/stoolpigeon/init_test.go b/stoolpigeon/init_test.go new file mode 100644 index 0000000..2089f49 --- /dev/null +++ b/stoolpigeon/init_test.go @@ -0,0 +1,31 @@ +/* + * Copyright 2018-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package stoolpigeon_test + +import ( + "testing" + + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" +) + +func TestUnit(t *testing.T) { + suite := spec.New("procfile", spec.Report(report.Terminal{})) + suite("Generate", testGenerate) + suite("Detect", testDetect) + suite.Run(t) +}