Skip to content

Commit

Permalink
Use artifact inventory (#814)
Browse files Browse the repository at this point in the history
* Implement VersionRequirement for Requirement

* Use Artifact in nodejs-engine

* Update inventory.toml with new artifact format

Logic for updating this from the nodejs.org feed will be added later

* Rename release to artifact

* Use Artifact directory for node DistLayerMetaData

* Prefer Artifact#Display over Version#Display

* Test output displays os and arch

* Print download source to buildpack output

* Update go buildpack revision

* Generalize tarball prefix extraction

Node tarballs are prefixed with the filename sans ".tar.gz", so this will allow extraction of arm64 artifacts as well.

* Verify checksum

* Resolve node artifact based on current os/arch

* Fix typo

* Reduce verbosity

* Simplify expression

* Add bin/update_node_inventory

* Update GitHub action for new inventory

* Reduce visibility

* Remove unnecessary comment

* Rename remote_artifacts to upstream_artifacts

* Fix error message

* Update comment

* Update earliest version variable name

* Prefer three member tuple

* Use exit code 1 consistently

Non-zero exit code values aren't used anywhere

* Remove unnecessary qualifier

* Simplify expression

* Prefer updating rust toolchain directly

Avoid dependency on an archived github action, and take the same approach as other workflows in this repository

* Use Rust cache

* Simplify method

It's clear what is happening here, so avoid assigning an "earliest version" variable/providing context for an error that'll be trivial to identify if it's ever changed.

* Use Result rather than custom process exits

When an error is encountered, the process will still be terminated with a non-zero exit code with adequate error information for debugging an issue written to stderr

* Inline list_upstream_artifacts logic in main fn

* Inline get_release_artifacts function

* Clone existing inventory artifacts

* Simplify expression
  • Loading branch information
runesoerensen authored May 9, 2024
1 parent 2ef5235 commit aeb50fe
Show file tree
Hide file tree
Showing 11 changed files with 7,011 additions and 8,753 deletions.
56 changes: 48 additions & 8 deletions .github/workflows/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,54 @@ on:

jobs:
update-nodejs-inventory:
name: Node.js
uses: ./.github/workflows/_update-inventory.yml
with:
name: Node.js
distribution: node
buildpack_id: heroku/nodejs-engine
buildpack_path: buildpacks/nodejs-engine
secrets: inherit
name: Update Node.js Inventory
runs-on: pub-hk-ubuntu-22.04-small
steps:
- uses: heroku/use-app-token-action@main
id: generate-token
with:
app_id: ${{ vars.LINGUIST_GH_APP_ID }}
private_key: ${{ secrets.LINGUIST_GH_PRIVATE_KEY }}

- name: Checkout Repo
uses: actions/checkout@v4

- name: Update Rust toolchain
run: rustup update

- name: Rust cache
uses: Swatinem/rust-cache@v2.7.3

- name: Rebuild Inventory
id: rebuild-inventory
run: |
delimiter="$(openssl rand -hex 8)"
{
echo "msg<<${delimiter}"
cargo run --bin update_node_inventory buildpacks/nodejs-engine/inventory.toml
echo "${delimiter}"
} >> $GITHUB_OUTPUT
- name: Update Changelog
run: echo "${{ steps.rebuild-inventory.outputs.msg }}" | xargs -r -I '{}' perl -i -p -e 's/\[Unreleased\]\s+/[Unreleased]\n\n- {}/' buildpacks/nodejs-engine/CHANGELOG.md

- name: Create Pull Request
id: pr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.generate-token.outputs.app_token }}
title: "Update Node.js Inventory"
commit-message: "Update Inventory for heroku/nodejs\n\n${{ steps.rebuild-inventory.outputs.msg }}"
committer: ${{ vars.LINGUIST_GH_APP_USERNAME }} <${{ vars.LINGUIST_GH_APP_EMAIL }}>
author: ${{ vars.LINGUIST_GH_APP_USERNAME }} <${{ vars.LINGUIST_GH_APP_EMAIL }}>
branch: update-nodejs-inventory
body: "Automated pull-request to update heroku/nodejs inventory:\n\n${{ steps.rebuild-inventory.outputs.msg }}"

- name: Configure PR
if: steps.pr.outputs.pull-request-operation == 'created'
env:
GH_TOKEN: ${{ steps.generate-token.outputs.app_token }}
run: gh pr merge --squash --auto "${{ steps.pr.outputs.pull-request-number }}"

update-yarn-inventory:
name: Yarn
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions buildpacks/nodejs-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ edition.workspace = true
workspace = true

[dependencies]
heroku-inventory-utils = { git = "https://github.com/heroku/buildpacks-go/", rev = "2a86fae18332b9bd495eb29422c13ac3fcb2d0dc" }
heroku-nodejs-utils.workspace = true
libcnb = { version = "=0.21.0", features = ["trace"] }
libherokubuildpack = { version = "=0.21.0", default-features = false, features = ["download", "fs", "log", "tar"] }
serde = "1"
sha2 = "0.10.8"
tempfile = "3"
thiserror = "1"
toml = "0.8"
Expand Down
Loading

0 comments on commit aeb50fe

Please sign in to comment.