-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f5f201
commit bd09a2d
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
module CleanJuliaFormatter | ||
using Test | ||
using TraitExtraction | ||
using Git | ||
using Logging | ||
using Pkg | ||
using JuliaFormatter | ||
|
||
function is_repo_clean(repo_path; ignore_untracked = true) | ||
# Get the status of the repository | ||
statuses = readlines(`$(Git.git()) status -s $repo_path`) | ||
|
||
if ignore_untracked | ||
# Repo must be clean except for untracked files | ||
statuses = filter((!) ∘ contains("??"), statuses) | ||
end | ||
|
||
is_clean = isempty(statuses) | ||
|
||
# If not clean then report on dirty files | ||
is_clean || @error "\n" * join(statuses, "\n") | ||
|
||
return is_clean | ||
end | ||
|
||
# Metadata crosswalk testing only works on Julia v1.8 and after due to Project.toml changes | ||
# Also does not currently work on Windows runners on GitHub due to file writing issues | ||
if VERSION ≥ VersionNumber("1.8.0") && | ||
(!haskey(ENV, "RUNNER_OS") || ENV["RUNNER_OS"] ≠ "Windows") | ||
@testset "JuliaFormatter" begin | ||
git_dir = readchomp(`$(Git.git()) rev-parse --show-toplevel`) | ||
@test_nowarn format(TraitExtraction) | ||
@test is_repo_clean(git_dir) | ||
end | ||
else | ||
@test_broken VERSION ≥ VersionNumber("1.8.0") && | ||
(!haskey(ENV, "RUNNER_OS") || ENV["RUNNER_OS"] ≠ "Windows") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
|
||
module CleanRSMD | ||
using Test | ||
using TraitExtraction | ||
using Git | ||
using Logging | ||
using Pkg | ||
using ResearchSoftwareMetadata | ||
|
||
function is_repo_clean(repo_path; ignore_untracked = true) | ||
# Get the status of the repository | ||
statuses = readlines(`$(Git.git()) status -s $repo_path`) | ||
|
||
if ignore_untracked | ||
# Repo must be clean except for untracked files | ||
statuses = filter((!) ∘ contains("??"), statuses) | ||
end | ||
|
||
is_clean = isempty(statuses) | ||
|
||
# If not clean then report on dirty files | ||
is_clean || @error "\n" * join(statuses, "\n") | ||
|
||
return is_clean | ||
end | ||
|
||
# Metadata crosswalk testing only works on Julia v1.8 and after due to Project.toml changes | ||
# Also does not currently work on Windows runners on GitHub due to file writing issues | ||
if VERSION ≥ VersionNumber("1.8.0") && | ||
(!haskey(ENV, "RUNNER_OS") || ENV["RUNNER_OS"] ≠ "Windows") | ||
@testset "RSMD" begin | ||
git_dir = readchomp(`$(Git.git()) rev-parse --show-toplevel`) | ||
@test isnothing(ResearchSoftwareMetadata.crosswalk()) | ||
global_logger(SimpleLogger(stderr, Logging.Warn)) | ||
@test_nowarn ResearchSoftwareMetadata.crosswalk() | ||
@test is_repo_clean(git_dir) | ||
end | ||
else | ||
@test_broken VERSION ≥ VersionNumber("1.8.0") && | ||
(!haskey(ENV, "RUNNER_OS") || ENV["RUNNER_OS"] ≠ "Windows") | ||
end | ||
|
||
end |