Skip to content

Commit

Permalink
Infra Improvements (#409)
Browse files Browse the repository at this point in the history
* Add script function to subtree a repo
* Add PR template
* Fix `spec` component test relying upon specific state of the repo's files
  • Loading branch information
Blacksmoke16 authored May 4, 2024
1 parent 94bf4e0 commit 490290a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 40 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Context

<!-- Take a minute to add some context for posterity as to what this PR is doing and why -->

## Changelog

<!-- List out the high level changes this PR makes, especially those that are breaking -->
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fetch-depth: 0
token: ${{ secrets.SYNC_TOKEN }}
- name: Sync Repos
run: ./scripts/sync.sh
run: ./scripts/repo.sh sync
env:
BEFORE_SHA: ${{ github.event.before }}
AFTER_SHA: ${{ github.event.after }}
Expand Down
55 changes: 55 additions & 0 deletions scripts/repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
## Based on https://github.com/laravel/framework/blob/d1ef8e588cc7efc3b3cf925b42f134aa54a4f9c7/bin/split.sh

set -e

CURRENT_BRANCH="master"

# Syncs the provided component if changes were made within the provided sub directory
#
# $1 - Sub directory path
# $2 - Component name
# $3 - Git URL
function maybeSync()
{
if ! $(git diff --quiet --exit-code $BEFORE_SHA $AFTER_SHA -- $1); then
echo "::group::Syncing $1"
git remote add $2 $3 || true
git fetch $2
git subtree push --prefix="$1" $2 $CURRENT_BRANCH
echo "::endgroup::"
fi
}

# Helper script to assist in managing the mono/many-repos
#
# sync - Syncs the monorepo out to the many-repos. ./scripts/repo.sh sync
# subtree - Initialize a new subtree repo. ./scripts/repo.sh subtree test 'Add the `example` component' src/components/test

METHOD=$1

case $METHOD in
sync)
maybeSync "src/components/clock" clock https://github.com/athena-framework/clock.git
maybeSync "src/components/console" console https://github.com/athena-framework/console.git
maybeSync "src/components/dependency_injection" dependency-injection https://github.com/athena-framework/dependency-injection.git
maybeSync "src/components/dotenv" dotenv https://github.com/athena-framework/dotenv.git
maybeSync "src/components/event_dispatcher" event-dispatcher https://github.com/athena-framework/event-dispatcher.git
maybeSync "src/components/image_size" image-size https://github.com/athena-framework/image-size.git
maybeSync "src/components/framework" framework https://github.com/athena-framework/framework.git
maybeSync "src/components/mercure" mercure https://github.com/athena-framework/mercure.git
maybeSync "src/components/negotiation" negotiation https://github.com/athena-framework/negotiation.git
maybeSync "src/components/routing" routing https://github.com/athena-framework/routing.git
maybeSync "src/components/serializer" serializer https://github.com/athena-framework/serializer.git
maybeSync "src/components/spec" spec https://github.com/athena-framework/spec.git
maybeSync "src/components/validator" validator https://github.com/athena-framework/validator.git

;;
subtree)
# $2 - Name of the `athena-framework` GH repo to subtree
# $3 - Commit message
# $4 - Path to target directory
git subtree add --squash --message="'$3'" --prefix="$4" "https://github.com/athena-framework/$2.git" master

;;
esac
37 changes: 0 additions & 37 deletions scripts/sync.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/spec/spec/methods_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe ASPEC::Methods do

describe ".run_executable", tags: "compiled" do
it "without input" do
run_executable "ls", ["./.github"] do |output, error, status|
output.should eq %(dependabot.yml\nworkflows\n)
run_executable "echo", ["foo", "bar"] do |output, error, status|
output.should eq "foo bar\n"
error.should be_empty
status.success?.should be_true
end
Expand Down

0 comments on commit 490290a

Please sign in to comment.