Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
The idea is that we write each inventory update to a unique file then use Github's https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs feature to store the file contents between jobs.

The second job can read in all the values and combine it into a single inventory file, from there we can write logic that will update an existing file with newer values. In theory this should all work
  • Loading branch information
schneems committed Nov 4, 2024
1 parent a6da00d commit 204df94
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ jobs:
- name: Output CHANGELOG
run: cargo run --bin ruby_changelog -- --version "${{inputs.ruby_version}}"
- name: Build Ruby
run: cargo run --bin ruby_build -- --version ${{inputs.ruby_version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}}
run: cargo run --bin ruby_build -- --version ${{inputs.ruby_version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}} --inventory "${{ matrix.base_image }}{{ matrix.arch }}-inventory.toml"
- name: Store inventory
id: store_inventory
run: |
echo "${{ matrix.base_image }}{{ matrix.arch }}=" > $GITHUB_OUTPUT
cat "${{ matrix.base_image }}{{ matrix.arch }}-inventory.toml | jq -r . >> $GITHUB_OUTPUT"
- name: Check Ruby
run: cargo run --bin ruby_check -- --version ${{inputs.ruby_version}} --base-image ${{matrix.base_image}} --arch ${{matrix.arch}} | tee $GITHUB_STEP_SUMMARY
- name: Upload Ruby runtime archive to S3 dry run
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,31 @@ jobs:
git diff --unified=0 remotes/origin/${{ github.base_ref }} ${{matrix.inventory}} | grep '^+' | grep -v '^+++' | cut -c2- > check_inventory.toml
- name: Check manifest URLs
run: cargo run --bin inventory_check -- check_inventory.toml

test-dependent-job:
runs-on: ubuntu-24.04
strategy:
matrix:
arch: ["amd64", "arm64"]
base_image: ["heroku-20", "heroku-22", "heroku-24"]
steps:
- name: Store inventory
id: store_inventory
run: |
echo "${{ matrix.base_image }}${{ matrix.arch }}=" > $GITHUB_OUTPUT
cat "${{ matrix.base_image }}${{ matrix.arch }}-inventory.toml | jq -r . >> $GITHUB_OUTPUT"
after-test-dependent-job:
runs-on: ubuntu-24.04
needs: test-dependent-job
steps:
- name: Output GITHUB_OUTPUT
run: echo ${{needs.test-dependent-job.outputs}}
- name: Combine results
run: |
echo "Combining results..."
for key in $(jq -r 'keys[]' <<< "${{ toJson(needs.test-dependent-job.outputs) }}"); do
value=$(jq -r --arg key "$key" '.[$key]' <<< "${{ toJson(needs.test-dependent-job.outputs) }}")
echo "$value" >> combined.txt
echo "" >> combined.txt
done
11 changes: 10 additions & 1 deletion ruby_executable/src/bin/ruby_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct RubyArgs {

#[arg(long = "base-image")]
base_image: BaseImage,

#[arg(long = "inventory", default_value = "ruby_inventory.yml")]
inventory: PathBuf,
}

fn ruby_dockerfile_contents(base_image: &BaseImage) -> String {
Expand Down Expand Up @@ -62,10 +65,16 @@ fn ruby_build(args: &RubyArgs) -> Result<(), Box<dyn std::error::Error>> {
arch,
version,
base_image,
inventory,
} = args;

let mut log = Print::new(std::io::stderr()).h1("Building Ruby");
let inventory = source_dir().join("ruby_inventory.toml");

let inventory = if inventory.is_absolute() {
inventory.clone()
} else {
source_dir().join(inventory)
};
let volume_cache_dir = source_dir().join("cache");
let volume_output_dir = source_dir().join("output");

Expand Down
5 changes: 5 additions & 0 deletions shared/src/bin/inventory_update.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! A CLI to combine two inventory files on disk with
// cargo run --bin inventory_update -- --update path/to/file --with path/to/other/file

fn main() {}

0 comments on commit 204df94

Please sign in to comment.