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

Improve transformation of the hyde/hyde composer.json in the monorepo split job #33

Merged
merged 6 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/split-monorepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ jobs:
- name: Load persisted data
run: wget https://raw.githubusercontent.com/hydephp/develop/${{ github.sha }}/build/monorepo/persist/hyde/README.md -O README.md

- name: Download composer fix script
run: wget https://gist.githubusercontent.com/caendesilva/8528ef3ab2f5d116c2b58af9ff1c211b/raw/01fcae28cdec1d26b0494331175b301a4e5b2852/fixcomposer.json.php -O fixcomposer.php
- name: Remove packages from composer.json
run: php fixcomposer.php
- name: Download composer update script
run: wget https://raw.githubusercontent.com/hydephp/develop/${{ github.sha }}/build/tools/update-composer.php -O update-composer.php
- name: Verify checksum matches
run: echo '25f06588b0e513532b446e7a305f0e7b91601abf update-composer.php' | shasum -c
- name: Update composer.json
run: php update-compose.php
- name: Delete script
run: rm fixcomposer.php
run: rm update-compose.php
- name: Remove composer.lock
run: rm -f composer.lock

Expand Down
1 change: 1 addition & 0 deletions build/tools/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25f06588b0e513532b446e7a305f0e7b91601abf update-composer.php
37 changes: 37 additions & 0 deletions build/tools/update-composer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

// Script to use in the Monorepo split action to update the root Composer.json
// creating one that works for the hyde/hyde project.

// We do two main things:
// 1. Replace dev-master versions with the configured versions.
// 2. Remove the package entries from the repositories configuration.

// Usage:
// This script is intended to be downloaded and run in split-monorepo.yml
// where it follows roughly the flow below:
// 1. Checkout ref readonly-hyde-mirror
// 2. Download the script to the root
// 3. Run the script, then delete it

// Checking the integrity of the script
// a) Generate the checksum file with shasum update-composer.php > checksums.txt
// b) Check that the checksums match with shasum -c checksums.txt

// Configuration settings
const frameworkVersion = '^0.35';
const rcVersion = '^2.1';
$time_start = microtime(true);
echo "Transforming composer.json\n";

$json = json_decode(file_get_contents('composer.json'), true);

$json['require']['hyde/framework'] = frameworkVersion;
$json['require-dev']['hyde/realtime-compiler'] = rcVersion;

unset($json['repositories']);

file_put_contents('composer.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

echo "Done. Finished in " . number_format((microtime(true) - $time_start) * 1000, 2) . "ms\n";
exit(0);