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

ci: separate workflows for main and dev branches #72

Merged
merged 5 commits into from
Nov 14, 2024
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
23 changes: 23 additions & 0 deletions .github/workflows/validation-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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"
}
git_upstream: >-
{
"clas12Tags": { "fork": "gemc/clas12Tags", "ref": "dev" }
}
9 changes: 6 additions & 3 deletions .github/workflows/validation-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 27 additions & 10 deletions util/latest.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/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
'both': return both file name and 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
Expand All @@ -35,17 +40,29 @@
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
puts configFiles.first
result = results.first
case output
when 'file'
puts result[:file]
when 'version'
puts result[:version]
when 'both'
puts result[:file] + ' ' + result[:version]
else
$stderr.puts "ERROR: unknown [OUTPUT] '#{output}'"
exit 1
end