Skip to content

Commit

Permalink
Don't create main branch when on main and don't run some tests on main
Browse files Browse the repository at this point in the history
The ReusableTest workflow creates a main branch due a specific test
recently introduced. That specific runs the generation on main and on
HEAD.
Both activites make no sense if we are running on the main branch.

This creates a condition on the workflow to only run if the branch is
not main (a condition on PRs would also work, but we leave the
possibility of running tests on others branches with this approach).
Furthermore, this also adds a condition in the tests such that only on
main the tests are run.

Closes #435
  • Loading branch information
abelsiqueira committed Sep 5, 2024
1 parent cd4d423 commit c89fb23
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ReusableTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
- name: Create branch main
if: github.ref != 'refs/heads/main'
run: |
git branch this-pr
git checkout origin/main
git branch --track main origin/main
Expand Down
68 changes: 35 additions & 33 deletions test/test-bestie-specific-api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,41 +205,43 @@ end
end
end

@testset "Test updating from main to HEAD vs generate in HEAD" begin
_with_tmp_dir() do dir
common_args = (defaults = true, quiet = true)
if read(`git branch --show-current`, String) != "main"
@testset "Test updating from main to HEAD vs generate in HEAD" begin
_with_tmp_dir() do dir
common_args = (defaults = true, quiet = true)

mkdir("gen_then_up")
cd("gen_then_up") do
# Generate the release version
BestieTemplate.generate(
C.template_path,
".",
C.args.bestie.req;
vcs_ref = "main",
common_args...,
)
_git_setup()
_full_precommit()
# Update using the HEAD version
BestieTemplate.update(".", C.args.bestie.req; vcs_ref = "HEAD", common_args...)
_full_precommit()
end
mkdir("gen_then_up")
cd("gen_then_up") do
# Generate the release version
BestieTemplate.generate(
C.template_path,
".",
C.args.bestie.req;
vcs_ref = "main",
common_args...,
)
_git_setup()
_full_precommit()
# Update using the HEAD version
BestieTemplate.update(".", C.args.bestie.req; vcs_ref = "HEAD", common_args...)
_full_precommit()
end

mkdir("gen_direct")
cd("gen_direct") do
# Generate directly in the HEAD version
BestieTemplate.generate(
C.template_path,
".",
C.args.bestie.req;
vcs_ref = "HEAD",
common_args...,
)
_git_setup()
_full_precommit()
end
mkdir("gen_direct")
cd("gen_direct") do
# Generate directly in the HEAD version
BestieTemplate.generate(
C.template_path,
".",
C.args.bestie.req;
vcs_ref = "HEAD",
common_args...,
)
_git_setup()
_full_precommit()
end

_test_diff_dir("gen_then_up", "gen_direct")
_test_diff_dir("gen_then_up", "gen_direct")
end
end
end

0 comments on commit c89fb23

Please sign in to comment.