-
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.
The initial implementation of a native (non-shimmed) libcnb.rs-based Python CNB.
- Loading branch information
Showing
66 changed files
with
4,873 additions
and
1 deletion.
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 @@ | ||
* @heroku/languages |
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,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
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,22 @@ | ||
name: Check Changelog | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, labeled, unlabeled, synchronize] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check-changelog: | ||
runs-on: ubuntu-latest | ||
if: | | ||
!contains(github.event.pull_request.labels.*.name, 'skip changelog') && | ||
!contains(github.event.pull_request.labels.*.name, 'dependencies') | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Check that CHANGELOG is touched | ||
run: | | ||
git fetch origin ${{ github.base_ref }} --depth 1 && \ | ||
git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md |
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,66 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
# Avoid duplicate builds on PRs. | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Update Rust toolchain | ||
run: rustup update | ||
- name: Rust Cache | ||
uses: Swatinem/[email protected] | ||
- name: Clippy | ||
run: cargo clippy --all-targets --locked -- --deny warnings | ||
- name: rustfmt | ||
run: cargo fmt -- --check | ||
|
||
unit-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Update Rust toolchain | ||
run: rustup update | ||
- name: Rust Cache | ||
uses: Swatinem/[email protected] | ||
- name: Run unit tests | ||
run: cargo test --locked | ||
|
||
integration-test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
builder: ["builder:22", "buildpacks:20"] | ||
env: | ||
INTEGRATION_TEST_CNB_BUILDER: heroku/${{ matrix.builder }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install musl-tools | ||
run: sudo apt-get install musl-tools --no-install-recommends | ||
- name: Update Rust toolchain | ||
run: rustup update | ||
- name: Install Rust linux-musl target | ||
run: rustup target add x86_64-unknown-linux-musl | ||
- name: Rust Cache | ||
uses: Swatinem/[email protected] | ||
- name: Install Pack CLI | ||
uses: buildpacks/github-actions/[email protected] | ||
- name: Run integration tests | ||
# Runs only tests annotated with the `ignore` attribute (which in this repo, are the integration tests). | ||
run: cargo test --locked -- --ignored --test-threads 5 |
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,80 @@ | ||
name: Release Buildpack | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
BUILDPACK_DOCKER_REPO: docker.io/heroku/buildpack-python | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
# Releases the buildpack to Docker Hub and registers it with the CNB Buildpack Registry. | ||
# This release process intentionally does not create a .cnb file release for now, since | ||
# there are currently no use-cases that need it for Python. | ||
release: | ||
name: Release heroku/python | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Setup | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install musl-tools | ||
run: sudo apt-get install musl-tools --no-install-recommends | ||
- name: Update Rust toolchain | ||
run: rustup update | ||
- name: Install Rust linux-musl target | ||
run: rustup target add x86_64-unknown-linux-musl | ||
- name: Rust Cache | ||
uses: Swatinem/[email protected] | ||
- name: Install libcnb-cargo | ||
run: cargo install libcnb-cargo | ||
- name: Install Pack CLI | ||
uses: buildpacks/github-actions/[email protected] | ||
- name: Install yj and crane | ||
uses: buildpacks/github-actions/[email protected] | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
# Build | ||
- name: Compile the buildpack | ||
run: cargo libcnb package --release | ||
|
||
# Publish | ||
- name: Read buildpack metadata | ||
run: | | ||
echo "buildpack_id=$(yj -t < buildpack.toml | jq -r .buildpack.id)" >> $GITHUB_ENV | ||
echo "buildpack_version=$(yj -t < buildpack.toml | jq -r .buildpack.version)" >> $GITHUB_ENV | ||
- name: Check version is unique on Docker Hub | ||
run: | | ||
if docker manifest inspect "${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" > /dev/null; then | ||
echo "Duplicate version found on Docker Hub ${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" | ||
exit 1 | ||
fi | ||
- name: Publish the buildpack to Docker Hub | ||
run: pack buildpack package --path target/buildpack/release/heroku_python --publish "${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }}" | ||
- name: Calculate the buildpack image digest | ||
run: echo "buildpack_digest=$(crane digest ${{ env.BUILDPACK_DOCKER_REPO }}:${{ env.buildpack_version }})" >> $GITHUB_ENV | ||
- name: Register the new version with the CNB Buildpack Registry | ||
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.0.1 | ||
with: | ||
token: ${{ secrets.CNB_REGISTRY_RELEASE_BOT_GITHUB_TOKEN }} | ||
id: ${{ env.buildpack_id }} | ||
version: ${{ env.buildpack_version }} | ||
address: ${{ env.BUILDPACK_DOCKER_REPO }}@${{ env.buildpack_digest }} | ||
- name: Create GitHub release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ env.buildpack_version }} | ||
release_name: v${{ env.buildpack_version }} | ||
body: | | ||
See the [CHANGELOG](./CHANGELOG.md) for details. | ||
draft: false |
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,3 @@ | ||
__pycache__/ | ||
target/ | ||
.DS_Store |
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,3 @@ | ||
{ | ||
"recommendations": ["rust-lang.rust-analyzer"], | ||
} |
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,6 @@ | ||
{ | ||
"rust-analyzer.check.command": "clippy", | ||
"rust-analyzer.imports.granularity.enforce": true, | ||
"rust-analyzer.imports.granularity.group": "module", | ||
"rust-analyzer.imports.prefix": "crate", | ||
} |
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 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
- Initial implementation. |
Oops, something went wrong.