99 # Triggers the workflow on pull request events.
1010 pull_request :
1111 types : [opened, reopened, synchronize]
12-
12+ schedule :
13+ - cron : 12 13 * * 1 # Weekly
1314 # Allows you to run this workflow manually from the Actions tab
1415 workflow_dispatch :
1516
@@ -19,7 +20,77 @@ concurrency:
1920 cancel-in-progress : true
2021
2122jobs :
22- # Since the name of the matrix job depends on the version, we define another job with a more stable name.
23+ orchestrate :
24+ runs-on : ubuntu-latest
25+ name : Prepare Tests
26+ outputs :
27+ supported_crdbs : ${{ steps.crdb.outputs.crdbs }}
28+ latest_crdb : ${{ steps.crdb.outputs.latest }}
29+ steps :
30+ - id : crdb
31+ name : Determine Supported CockroachDB Versions
32+ shell : ruby -rcsv -rjson -rnet/http -ruri {0}
33+ run : |
34+ p ENV["GITHUB_OUTPUT"]
35+ link = "https://raw.githubusercontent.com/cockroachdb/docs/7c75d7596ae144c30f341b5b337b5775088f29df/src/current/_data/versions.csv"
36+
37+ uri = URI.parse(link)
38+ data = Net::HTTP.get(uri)
39+ csv = CSV.parse(data, headers: true)
40+
41+ versions = csv.filter_map do |row|
42+ support = row["asst_supp_exp_date"]
43+ support = row["maint_supp_exp_date"] if support == "N/A"
44+
45+ row["major_version"] if Date.parse(support) >= Date.today
46+ end
47+ p versions
48+
49+ File.write(ENV["GITHUB_OUTPUT"], "crdbs=#{JSON.generate(versions)}\n", mode: ?a)
50+ File.write(ENV["GITHUB_OUTPUT"], "latest=#{JSON.generate(versions.max)}\n", mode: ?a)
51+
52+
53+ puts File.read(ENV["GITHUB_OUTPUT"])
54+
55+ test :
56+ runs-on : ubuntu-latest
57+ needs : orchestrate
58+ continue-on-error : ${{ matrix.experimental }}
59+ strategy :
60+ fail-fast : false
61+ matrix :
62+ # https://www.cockroachlabs.com/docs/releases/release-support-policy
63+ crdb : ${{ fromJSON(needs.orchestrate.outputs.supported_crdbs) }}
64+ ruby : ["3.4"]
65+ rails : ["8-1-stable"]
66+ experimental : [false]
67+ include :
68+ - crdb : ${{ fromJSON(needs.orchestrate.outputs.latest_crdb) }}
69+ ruby : " 3.4"
70+ rails : " main"
71+ experimental : true
72+ name : Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }} rails=${{ matrix.rails }})
73+ steps :
74+ - name : Set Up Actions
75+ uses : actions/checkout@v4
76+ - uses : ./.github/actions/test-runner
77+ id : test
78+ with :
79+ crdb : ${{ matrix.crdb }}
80+ ruby : ${{ matrix.ruby }}
81+ env :
82+ RAILS_TAG : ${{ matrix.rails }}
83+ JSON_REPORTER : " report.json"
84+ - name : Upload Report
85+ if : ${{ failure() && steps.test.conclusion == 'failure' }}
86+ uses : actions/upload-artifact@v4
87+ with :
88+ name : report-${{ matrix.crdb }}-${{ matrix.ruby }}
89+ path : report.json
90+ # Since the name of the matrix job depends on the
91+ # version, we define another job with a more stable
92+ # name. We also aggregate failed tests to display
93+ # in the Github Summary.
2394 test_results :
2495 if : ${{ always() }}
2596 runs-on : ubuntu-latest
@@ -92,29 +163,3 @@ jobs:
92163 echo '```json' >>$GITHUB_STEP_SUMMARY
93164 jq --slurp --compact-output '.' reports/*/report.json >>$GITHUB_STEP_SUMMARY
94165 echo '```' >>$GITHUB_STEP_SUMMARY
95-
96- test :
97- runs-on : ubuntu-latest
98- strategy :
99- fail-fast : false
100- matrix :
101- # https://www.cockroachlabs.com/docs/releases/release-support-policy
102- crdb : [v24.3, v25.1, v25.2, v25.3]
103- ruby : ["3.4"]
104- name : Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }})
105- steps :
106- - name : Set Up Actions
107- uses : actions/checkout@v4
108- - uses : ./.github/actions/test-runner
109- id : test
110- with :
111- crdb : ${{ matrix.crdb }}
112- ruby : ${{ matrix.ruby }}
113- env :
114- JSON_REPORTER : " report.json"
115- - name : Upload Report
116- if : ${{ failure() && steps.test.conclusion == 'failure' }}
117- uses : actions/upload-artifact@v4
118- with :
119- name : report-${{ matrix.crdb }}-${{ matrix.ruby }}
120- path : report.json
0 commit comments