Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation #3

Merged
merged 71 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
719f105
Functions MVP
edmorley Dec 9, 2022
d87a78d
Install salesforce-functions from PyPI now it's been published
edmorley Dec 14, 2022
4e5ba1e
Fix CI after salesforce-functions 0.2.0 release
edmorley Jan 2, 2023
fca044c
Bump minimum Rust version to 1.66
edmorley Jan 2, 2023
406f255
Only use major versions in Cargo.toml
edmorley Jan 2, 2023
f687559
Skip check changelog for Dependabot PRs
edmorley Jan 2, 2023
35a6dde
Refresh lockfile
edmorley Jan 2, 2023
11efc72
Remove support for skipping check-changelog using the PR description
edmorley Jan 6, 2023
f518418
Update buildpacks/github-actions to 5.0.1
edmorley Jan 6, 2023
cc2fb09
Remove workarounds for slow M1 performance
edmorley Jan 14, 2023
d0ed798
Refresh Cargo.lock
edmorley Jan 17, 2023
fb848be
Update test after salesforce-functions v0.3.0 release
edmorley Jan 17, 2023
a4abc3f
Remove functions integration test for too-old Python
edmorley Jan 27, 2023
40aa0af
Remove caching support from the pip layer
edmorley Jan 27, 2023
2abc573
Add VSCode configs
edmorley Jan 27, 2023
ef88b80
Bump minimum Rust version to 1.67
edmorley Jan 27, 2023
1be9dc4
Refresh Cargo.lock
edmorley Jan 27, 2023
42343e3
Switch Dependabot to monthly
edmorley Jan 27, 2023
3489dc5
Switch GitHub Action runner image back to `ubuntu-latest`
edmorley Jan 27, 2023
eb98a86
Remove now-unused test fixture
edmorley Jan 27, 2023
47d06d5
Pass detect for non-functions too
edmorley Jan 28, 2023
76c2822
Update to pip 23.0, setuptools 67.0.0, wheel 0.38.4
edmorley Jan 31, 2023
da42891
Clean up functions handling
edmorley Feb 1, 2023
1ac2ec6
More unit tests, rustdocs and comments
edmorley Feb 1, 2023
448921e
Switch buildpack ID back to `heroku/python`
edmorley Feb 1, 2023
92046bb
Test `heroku/buildpacks:20` in CI too
edmorley Feb 1, 2023
6c32581
Shorten CI job name
edmorley Feb 1, 2023
d849fae
Update Cargo dependencies
edmorley Feb 3, 2023
f85f39d
Update to setuptools 67.1.0
edmorley Feb 3, 2023
bbe592d
Remove notes.md
edmorley Feb 3, 2023
d5bb909
Update LICENSE year
edmorley Feb 3, 2023
2f66e68
Move fixtures under tests/fixtures/
edmorley Feb 3, 2023
7387625
Switch check-changelog to `ubuntu-latest`
edmorley Feb 3, 2023
8ef2a84
Fix functions integration test after 0.5.0 release
edmorley Feb 3, 2023
70373e5
Add CHANGELOG.md
edmorley Feb 3, 2023
1d2db46
Only run CI on PRs not branches
edmorley Feb 3, 2023
a53fd3e
Switch from env var to `--disable-pip-version-check`
edmorley Feb 7, 2023
c9bae31
Python/pip layer refactoring + unit tests
edmorley Feb 7, 2023
631b212
Refresh Cargo.lock
edmorley Feb 7, 2023
391519e
Cleanup errors.rs
edmorley Feb 7, 2023
bb01b50
Add `.env_clear()` to all `Command` usages
edmorley Feb 8, 2023
49fdb60
Refactor pip dependencies layer env handling + add a test
edmorley Feb 8, 2023
2b6bf42
s/env/command_env/
edmorley Feb 9, 2023
4ad4245
More rustdocs/comments
edmorley Feb 9, 2023
09083da
s/functions/salesforce_functions/
edmorley Feb 9, 2023
ea35f11
Improve naming of error enums and their variants
edmorley Feb 9, 2023
401984a
Clean up SOURCE_DATE_EPOCH usages
edmorley Feb 9, 2023
7e5873b
Bump default Python to the newly released 3.11.2
edmorley Feb 10, 2023
f8ccc42
Switch back to using `PIP_DISABLE_PIP_VERSION_CHECK`
edmorley Feb 16, 2023
1924ef0
Add integration tests
edmorley Feb 16, 2023
a8febff
Try `--test-threads 10` for integration tests in CI
edmorley Feb 20, 2023
a7e3148
`--test-threads 6`
edmorley Feb 20, 2023
544dba9
`--test-threads 4`
edmorley Feb 20, 2023
04d0c16
`--test-threads 5`
edmorley Feb 20, 2023
fa4b16e
Update Swatinem/rust-cache to v2.2.1
edmorley Feb 24, 2023
457a017
Improve cache and logging
edmorley Feb 24, 2023
583b04f
Refactor Python runtime archive URL generation
edmorley Feb 27, 2023
2a92049
Update dependencies
edmorley Feb 27, 2023
9bc83dd
Refactor PackagingToolVersions
edmorley Feb 27, 2023
9048996
More rustdocs
edmorley Feb 27, 2023
c602666
Refactor integration tests
edmorley Feb 28, 2023
ff1c62c
Add work item numbers to some of the TODOs
edmorley Feb 28, 2023
f22600c
Misc cleanup
edmorley Mar 1, 2023
b189360
Address review comments
edmorley Mar 1, 2023
e95f00e
Add a release script
edmorley Mar 1, 2023
630d74f
Add duplicate version check to release workflow
edmorley Mar 1, 2023
7dce0d5
Fix comment typo
edmorley Mar 3, 2023
1922305
Clarify comment about env var inheritance
edmorley Mar 6, 2023
55349e4
Fix comment typo in package_manager.rs
edmorley Mar 6, 2023
b2b796f
Update to setuptools 67.5.0
edmorley Mar 6, 2023
dd390e9
Refresh Cargo.lock
edmorley Mar 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @heroku/languages
10 changes: 10 additions & 0 deletions .github/dependabot.yml
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"
22 changes: 22 additions & 0 deletions .github/workflows/check_changelog.yml
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
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
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:
edmorley marked this conversation as resolved.
Show resolved Hide resolved
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.1
- 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/rust-cache@v2.2.1
- 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/rust-cache@v2.2.1
- name: Install Pack CLI
uses: buildpacks/github-actions/setup-pack@v5.0.1
- 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
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
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/rust-cache@v2.2.1
- name: Install libcnb-cargo
run: cargo install libcnb-cargo
- name: Install Pack CLI
uses: buildpacks/github-actions/setup-pack@v5.0.1
- name: Install yj and crane
uses: buildpacks/github-actions/setup-tools@v5.0.1
- 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
target/
.DS_Store
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["rust-lang.rust-analyzer"],
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
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",
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
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.