Skip to content

Commit 1cec039

Browse files
committed
solana version matrix workaround
1 parent 5596fba commit 1cec039

File tree

2 files changed

+128
-108
lines changed

2 files changed

+128
-108
lines changed

.github/workflows/solana-native.yml

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
native:
3737
- added|modified: '**/native/**'
3838
workflow:
39-
- added|modified: '.github/workflows/solana-native.yml'
39+
- added|modified: '.github/workflows/native.yml'
4040
- name: Analyze Changes
4141
id: analyze
4242
run: |
@@ -97,106 +97,119 @@ jobs:
9797
strategy:
9898
fail-fast: false
9999
matrix:
100-
node-version: [20.x]
101-
solana-version: [1.18.17, stable]
102100
index: ${{ fromJson(needs.changes.outputs.matrix) }}
103101
name: build-and-test-group-${{ matrix.index }}
104102
outputs:
105103
failed_projects: ${{ steps.set-failed.outputs.failed_projects }}
106104
steps:
107105
- uses: actions/checkout@v4
108-
- name: Use Node.js ${{ matrix.node-version }}
106+
- name: Use Node.js
109107
uses: actions/setup-node@v4
110108
with:
111-
node-version: ${{ matrix.node-version }}
109+
node-version: 20.x
112110
check-latest: true
113-
- uses: heyAyushh/[email protected]
114-
with:
115-
solana-cli-version: ${{ matrix.solana-version }}
116-
- run: |
117-
solana -V
118-
rustc -V
119-
shell: bash
120-
- name: Install pnpm
121-
run: npm install --global pnpm
122-
- name: Build and Test
123-
env:
124-
TOTAL_PROJECTS: ${{ needs.changes.outputs.total_projects }}
125-
PROJECTS_PER_JOB: ${{ env.MIN_PROJECTS_PER_JOB }}
111+
- name: Setup build environment
112+
id: setup
126113
run: |
114+
# Create the build and test function
115+
cat << 'EOF' > build_and_test.sh
127116
function build_and_test() {
128117
local project=$1
129-
echo "Building and Testing $project"
118+
local solana_version=$2
119+
echo "Building and Testing $project with Solana $solana_version"
130120
cd "$project" || return 1
131121
132122
# Install dependencies
133123
if ! pnpm install --frozen-lockfile; then
134124
echo "::error::pnpm install failed for $project"
135-
echo "$project: pnpm install failed" >> $GITHUB_WORKSPACE/failed_projects.txt
125+
echo "$project: pnpm install failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
136126
cd - > /dev/null
137127
return 1
138128
fi
139129
140130
# Build
141131
if ! pnpm build; then
142132
echo "::error::build failed for $project"
143-
echo "$project: build failed" >> $GITHUB_WORKSPACE/failed_projects.txt
133+
echo "$project: build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
144134
cd - > /dev/null
145135
return 1
146136
fi
147137
148138
# Test
149139
if ! pnpm build-and-test; then
150140
echo "::error::tests failed for $project"
151-
echo "$project: tests failed" >> $GITHUB_WORKSPACE/failed_projects.txt
141+
echo "$project: tests failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
152142
cd - > /dev/null
153143
return 1
154144
fi
155145
156-
echo "Build and tests succeeded for $project."
146+
echo "Build and tests succeeded for $project with $solana_version version."
157147
cd - > /dev/null
158148
return 0
159149
}
160150
161-
# Determine which projects to build in this job
162-
readarray -t all_projects < <(echo '${{ needs.changes.outputs.changed_projects }}' | jq -r '.[]?')
163-
start_index=$(( ${{ matrix.index }} * PROJECTS_PER_JOB ))
164-
end_index=$(( start_index + PROJECTS_PER_JOB ))
165-
end_index=$(( end_index > TOTAL_PROJECTS ? TOTAL_PROJECTS : end_index ))
151+
function process_projects() {
152+
local solana_version=$1
166153
167-
echo "Projects to build and test in this job"
168-
for i in $(seq $start_index $(( end_index - 1 ))); do
169-
echo "${all_projects[$i]}"
170-
done
154+
readarray -t all_projects < <(echo '${{ needs.changes.outputs.changed_projects }}' | jq -r '.[]?')
155+
start_index=$(( ${{ matrix.index }} * ${{ env.MIN_PROJECTS_PER_JOB }} ))
156+
end_index=$(( start_index + ${{ env.MIN_PROJECTS_PER_JOB }} ))
157+
end_index=$(( end_index > ${{ needs.changes.outputs.total_projects }} ? ${{ needs.changes.outputs.total_projects }} : end_index ))
171158
172-
# Build and test projects
173-
failed=false
174-
failed_projects=()
175-
for i in $(seq $start_index $(( end_index - 1 ))); do
176-
echo "::group::Building and testing ${all_projects[$i]}"
177-
if ! build_and_test "${all_projects[$i]}"; then
178-
failed=true
179-
failed_projects+=("${all_projects[$i]}")
180-
fi
181-
echo "::endgroup::"
182-
done
159+
echo "Projects to build and test in this job"
160+
for i in $(seq $start_index $(( end_index - 1 ))); do
161+
echo "${all_projects[$i]}"
162+
done
183163
184-
if [[ "$failed" == "true" ]]; then
185-
echo "::group::Failed projects"
186-
cat $GITHUB_WORKSPACE/failed_projects.txt
187-
echo "::endgroup::"
188-
echo "failed_projects=${failed_projects[@]}" >> $GITHUB_OUTPUT
189-
exit 1
190-
else
191-
echo "failed_projects=" >> $GITHUB_OUTPUT
192-
fi
164+
failed=false
165+
for i in $(seq $start_index $(( end_index - 1 ))); do
166+
echo "::group::Building and testing ${all_projects[$i]}"
167+
if ! build_and_test "${all_projects[$i]}" "$solana_version"; then
168+
failed=true
169+
fi
170+
echo "::endgroup::"
171+
done
172+
173+
return $([ "$failed" = true ] && echo 1 || echo 0)
174+
}
175+
EOF
176+
177+
# Make the script executable
178+
chmod +x build_and_test.sh
179+
180+
# Install pnpm
181+
npm install --global pnpm
182+
- name: Test with Solana stable
183+
uses: heyAyushh/[email protected]
184+
with:
185+
solana-cli-version: stable
186+
- name: Build and Test with Stable
187+
run: |
188+
source build_and_test.sh
189+
solana -V
190+
rustc -V
191+
process_projects "stable"
192+
- name: Test with Solana 1.18.17
193+
uses: heyAyushh/[email protected]
194+
with:
195+
solana-cli-version: 1.18.17
196+
- name: Build and Test with 1.18.17
197+
run: |
198+
source build_and_test.sh
199+
solana -V
200+
rustc -V
201+
process_projects "1.18.17"
193202
194203
- name: Set failed projects output
195204
id: set-failed
196205
if: failure()
197206
run: |
198-
failed_projects=$(cat $GITHUB_WORKSPACE/failed_projects.txt | jq -R -s -c 'split("\n")[:-1]')
199-
echo "failed_projects=$failed_projects" >> $GITHUB_OUTPUT
207+
if [ -f "$GITHUB_WORKSPACE/failed_projects.txt" ]; then
208+
failed_projects=$(cat $GITHUB_WORKSPACE/failed_projects.txt | jq -R -s -c 'split("\n")[:-1]')
209+
echo "failed_projects=$failed_projects" >> $GITHUB_OUTPUT
210+
else
211+
echo "failed_projects=[]" >> $GITHUB_OUTPUT
212+
fi
200213
201214
summary:
202215
needs: [changes, build-and-test]

.github/workflows/steel.yml

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -97,103 +97,110 @@ jobs:
9797
strategy:
9898
fail-fast: false
9999
matrix:
100-
node-version: [20.x]
101-
solana-version: [1.18.17, stable]
102100
index: ${{ fromJson(needs.changes.outputs.matrix) }}
103101
name: build-and-test-group-${{ matrix.index }}
104102
outputs:
105103
failed_projects: ${{ steps.set-failed.outputs.failed_projects }}
106104
steps:
107105
- uses: actions/checkout@v4
108-
- name: Use Node.js ${{ matrix.node-version }}
106+
- name: Use Node.js
109107
uses: actions/setup-node@v4
110108
with:
111-
node-version: ${{ matrix.node-version }}
109+
node-version: 20.x
112110
check-latest: true
113-
- uses: heyAyushh/[email protected]
114-
with:
115-
solana-cli-version: ${{ matrix.solana-version }}
116-
- run: solana block
117-
shell: bash
118-
- name: Install pnpm
119-
run: npm install --global pnpm
120-
- name: Build and Test
121-
env:
122-
TOTAL_PROJECTS: ${{ needs.changes.outputs.total_projects }}
123-
PROJECTS_PER_JOB: ${{ env.MIN_PROJECTS_PER_JOB }}
111+
- name: Setup build environment
112+
id: setup
124113
run: |
114+
# Create the build and test function
115+
cat << 'EOF' > build_and_test.sh
125116
function build_and_test() {
126117
local project=$1
127-
echo "Building and Testing $project"
118+
local solana_version=$2
119+
echo "Building and Testing $project with Solana $solana_version"
128120
cd "$project" || return 1
129121
130-
# Install dependencies and build
122+
# Install dependencies
131123
if ! pnpm install --frozen-lockfile; then
132124
echo "::error::pnpm install failed for $project"
133-
echo "$project: pnpm install failed" >> $GITHUB_WORKSPACE/failed_projects.txt
125+
echo "$project: pnpm install failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
134126
cd - > /dev/null
135127
return 1
136128
fi
137129
130+
# Build
138131
if ! pnpm build; then
139132
echo "::error::build failed for $project"
140-
echo "$project: build failed" >> $GITHUB_WORKSPACE/failed_projects.txt
133+
echo "$project: build failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
141134
cd - > /dev/null
142135
return 1
143136
fi
144137
145-
# Run tests
138+
# Test
146139
if ! pnpm build-and-test; then
147140
echo "::error::tests failed for $project"
148-
echo "$project: tests failed" >> $GITHUB_WORKSPACE/failed_projects.txt
141+
echo "$project: tests failed with $solana_version" >> $GITHUB_WORKSPACE/failed_projects.txt
149142
cd - > /dev/null
150143
return 1
151144
fi
152145
153-
echo "Build and tests succeeded for $project."
146+
echo "Build and tests succeeded for $project with $solana_version version."
154147
cd - > /dev/null
155148
return 0
156149
}
157150
158-
# Determine which projects to build in this job
159-
readarray -t all_projects < <(echo '${{ needs.changes.outputs.changed_projects }}' | jq -r '.[]?')
160-
start_index=$(( ${{ matrix.index }} * PROJECTS_PER_JOB ))
161-
end_index=$(( start_index + PROJECTS_PER_JOB ))
162-
end_index=$(( end_index > TOTAL_PROJECTS ? TOTAL_PROJECTS : end_index ))
163-
164-
echo "Projects to build and test in this job"
165-
for i in $(seq $start_index $(( end_index - 1 ))); do
166-
echo "${all_projects[$i]}"
167-
done
151+
function process_projects() {
152+
local solana_version=$1
153+
154+
readarray -t all_projects < <(echo '${{ needs.changes.outputs.changed_projects }}' | jq -r '.[]?')
155+
start_index=$(( ${{ matrix.index }} * ${{ env.MIN_PROJECTS_PER_JOB }} ))
156+
end_index=$(( start_index + ${{ env.MIN_PROJECTS_PER_JOB }} ))
157+
end_index=$(( end_index > ${{ needs.changes.outputs.total_projects }} ? ${{ needs.changes.outputs.total_projects }} : end_index ))
158+
159+
echo "Projects to build and test in this job"
160+
for i in $(seq $start_index $(( end_index - 1 ))); do
161+
echo "${all_projects[$i]}"
162+
done
163+
164+
failed=false
165+
for i in $(seq $start_index $(( end_index - 1 ))); do
166+
echo "::group::Building and testing ${all_projects[$i]}"
167+
if ! build_and_test "${all_projects[$i]}" "$solana_version"; then
168+
failed=true
169+
fi
170+
echo "::endgroup::"
171+
done
172+
173+
return $([ "$failed" = true ] && echo 1 || echo 0)
174+
}
175+
EOF
168176
169-
# Build and test projects
170-
failed=false
171-
failed_projects=()
172-
for i in $(seq $start_index $(( end_index - 1 ))); do
173-
echo "::group::Building and testing ${all_projects[$i]}"
174-
if ! build_and_test "${all_projects[$i]}"; then
175-
failed=true
176-
failed_projects+=("${all_projects[$i]}")
177-
fi
178-
echo "::endgroup::"
179-
done
177+
# Make the script executable
178+
chmod +x build_and_test.sh
180179
181-
if [[ "$failed" == "true" ]]; then
182-
echo "::group::Failed projects"
183-
cat $GITHUB_WORKSPACE/failed_projects.txt
184-
echo "::endgroup::"
185-
echo "failed_projects=${failed_projects[@]}" >> $GITHUB_OUTPUT
186-
exit 1
187-
else
188-
echo "failed_projects=" >> $GITHUB_OUTPUT
189-
fi
180+
# Install pnpm
181+
npm install --global pnpm
182+
- name: Test with Solana stable
183+
uses: heyAyushh/[email protected]
184+
with:
185+
solana-cli-version: stable
186+
- name: Build and Test with Stable
187+
run: |
188+
source build_and_test.sh
189+
solana block
190+
solana -V
191+
rustc -V
192+
process_projects "stable"
190193
191194
- name: Set failed projects output
192195
id: set-failed
193196
if: failure()
194197
run: |
195-
failed_projects=$(cat $GITHUB_WORKSPACE/failed_projects.txt | jq -R -s -c 'split("\n")[:-1]')
196-
echo "failed_projects=$failed_projects" >> $GITHUB_OUTPUT
198+
if [ -f "$GITHUB_WORKSPACE/failed_projects.txt" ]; then
199+
failed_projects=$(cat $GITHUB_WORKSPACE/failed_projects.txt | jq -R -s -c 'split("\n")[:-1]')
200+
echo "failed_projects=$failed_projects" >> $GITHUB_OUTPUT
201+
else
202+
echo "failed_projects=[]" >> $GITHUB_OUTPUT
203+
fi
197204
198205
summary:
199206
needs: [changes, build-and-test]

0 commit comments

Comments
 (0)