From 81a1441e1abef912981e0ebf9430bba14b0d7669 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 12 Nov 2024 10:38:03 -0500 Subject: [PATCH 1/5] ci: separate workflows for `main` and `dev` branches Respects https://github.com/JeffersonLab/clas12-validation/pull/147 --- .github/workflows/validation-dev.yml | 19 +++++++++++++++++++ .github/workflows/validation-latest.yml | 9 ++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/validation-dev.yml diff --git a/.github/workflows/validation-dev.yml b/.github/workflows/validation-dev.yml new file mode 100644 index 0000000..b6b7445 --- /dev/null +++ b/.github/workflows/validation-dev.yml @@ -0,0 +1,19 @@ +name: Validation-dev + +on: + pull_request: + branches: [ dev ] # PRs which target `dev` + push: + branches: [ dev ] # pushes on `dev` (and merging PRs to `dev`) + workflow_dispatch: # manual trigger + +jobs: + validation: + uses: JeffersonLab/clas12-validation/.github/workflows/ci.yml@main + with: + gemc_version: build + config_file_versions: >- + { + "coatjava": "latest", + "gemc": "dev" + } diff --git a/.github/workflows/validation-latest.yml b/.github/workflows/validation-latest.yml index a821bd8..0a1ee58 100644 --- a/.github/workflows/validation-latest.yml +++ b/.github/workflows/validation-latest.yml @@ -2,11 +2,14 @@ name: Validation-latest on: pull_request: + branches-ignore: [ dev ] # PRs which do not target `dev` (cf. `validation-dev.yml`) push: - branches: [ main ] - tags: [ '*' ] - workflow_dispatch: + branches: [ main ] # pushes on `main` (viz., merging PRs to `main`) + tags: [ '*' ] # any tags + workflow_dispatch: # manual trigger jobs: validation: uses: JeffersonLab/clas12-validation/.github/workflows/ci.yml@main + with: + gemc_version: match_gcard From 6010b04a8a1aad7799733724438010e399dd0003 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 12 Nov 2024 22:38:14 -0500 Subject: [PATCH 2/5] feat: `latest.rb` can return just the version num --- util/latest.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/util/latest.rb b/util/latest.rb index 0af31fa..35861d8 100755 --- a/util/latest.rb +++ b/util/latest.rb @@ -1,15 +1,19 @@ #!/usr/bin/env ruby -unless ARGV.length == 2 - $stderr.puts """USAGE: #{$0} [SUBDIRECTORY] [CONFIG_BASENAME] - - obtain the latest version of the config file with basename [CONFIG] from +if ARGV.length < 2 + $stderr.puts """USAGE: #{$0} [SUBDIRECTORY] [CONFIG_BASENAME] [OUTPUT] + - obtain the latest version of the config file with basename [CONFIG] from [SUBDIRECTORY], assuming [SUBDIRECTORY] contains subdirectories of tag names - tag names that are not semantic version numbers, such as `dev`, are ignored + - [OUTPUT] may be either: + 'file': return the file name (default behavior) + 'version': return just the version number """ exit 2 end -subdir, config = ARGV +subdir, config = ARGV[0..1] +output = ARGV.length >= 3 ? ARGV[2] : 'file' unless Dir.exist? subdir $stderr.puts "ERROR: subdirectory '#{subdir}' does not exist" exit 1 @@ -48,4 +52,12 @@ end # return the latest version of that config file -puts configFiles.first +case output +when 'file' + puts configFiles.first +when 'version' + puts tagdirs.first +else + $stderr.puts "ERROR: unknown [OUTPUT] '#{output}'" + exit 1 +end From 70edd13b5293f635fc24d3c8f7566441c67be69c Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 12 Nov 2024 22:50:04 -0500 Subject: [PATCH 3/5] feat: another output --- util/latest.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/latest.rb b/util/latest.rb index 35861d8..2c72c47 100755 --- a/util/latest.rb +++ b/util/latest.rb @@ -8,6 +8,7 @@ - [OUTPUT] may be either: 'file': return the file name (default behavior) 'version': return just the version number + 'both': return both file name and version number """ exit 2 end @@ -57,6 +58,8 @@ puts configFiles.first when 'version' puts tagdirs.first +when 'both' + puts configFiles.first + ' ' + tagdirs.first else $stderr.puts "ERROR: unknown [OUTPUT] '#{output}'" exit 1 From 481031ffeb5700228a9712fe8486d25609b4d46b Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 13 Nov 2024 12:31:03 -0500 Subject: [PATCH 4/5] fix: make sure the version number matches the file --- util/latest.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/util/latest.rb b/util/latest.rb index 2c72c47..6fe8369 100755 --- a/util/latest.rb +++ b/util/latest.rb @@ -40,26 +40,28 @@ end # find the config files with the requested basename -configFiles = tagdirs.map{ |v| - Dir.glob("#{subdir}/#{v}/*").find{ |f| +results = Array.new +tagdirs.each do |v| + configFile = Dir.glob("#{subdir}/#{v}/*").find{ |f| File.basename(f).match? /^#{config}\./ } -} - .compact + results << { :version=>v, :file=>configFile } unless configFile.nil? +end -if configFiles.empty? +if results.empty? $stderr.puts "ERROR: cannot find config file with basename '#{config}' in any versioned subdirectory of '#{subdir}'" exit 1 end # return the latest version of that config file +result = results.first case output when 'file' - puts configFiles.first + puts result[:file] when 'version' - puts tagdirs.first + puts result[:version] when 'both' - puts configFiles.first + ' ' + tagdirs.first + puts result[:file] + ' ' + result[:version] else $stderr.puts "ERROR: unknown [OUTPUT] '#{output}'" exit 1 From ff5a00e33f6d472b7a870f705d81431c98fe2196 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Wed, 13 Nov 2024 15:00:31 -0500 Subject: [PATCH 5/5] fix: `validation-dev` should use `clas12Tags` ref `dev` --- .github/workflows/validation-dev.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/validation-dev.yml b/.github/workflows/validation-dev.yml index b6b7445..e7046e7 100644 --- a/.github/workflows/validation-dev.yml +++ b/.github/workflows/validation-dev.yml @@ -17,3 +17,7 @@ jobs: "coatjava": "latest", "gemc": "dev" } + git_upstream: >- + { + "clas12Tags": { "fork": "gemc/clas12Tags", "ref": "dev" } + }