Skip to content

Commit c86c55d

Browse files
- Building only when required.
1 parent 6fa496b commit c86c55d

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,12 +1186,38 @@ jobs:
11861186
11871187
- name: Image env sanitize
11881188
run: |
1189+
BUILD_IMAGE_REQUIRED="true"
1190+
PUSH_IMAGE_REQUIRED="false"
1191+
if ( \
1192+
[ "${{ github.repository }}" = "stackql/stackql" ] \
1193+
|| [ "${{ github.repository }}" != "stackql/stackql-devel" ] \
1194+
) \
1195+
&& [ "${{ vars.CI_SKIP_DOCKER_PUSH }}" != "true" ] \
1196+
&& ( \
1197+
[ "${{ github.ref_type }}" == "branch" ] \
1198+
&& [ "${{ github.ref_name }}" == "main" ] \
1199+
&& [ "${{ github.event_name }}" == push" ] \
1200+
) \
1201+
|| ( \
1202+
[ "${{ github.ref_type }}" = "tag" ] \
1203+
&& [ "$( grep '^build-release.*' <<< '${{ github.ref_name }}' )" != "" ] \
1204+
); \
1205+
then
1206+
PUSH_IMAGE_REQUIRED="true"
1207+
fi
1208+
if [ "${{ matrix.platform }}" == "linux/arm64" ] && [ "${PUSH_IMAGE_REQUIRED}" = "false" ]; then
1209+
BUILD_IMAGE_REQUIRED="false"
1210+
fi
11891211
{
11901212
echo "IMAGE_PLATFORM_SAN=$( sed 's/\//_/g' <<< '${{ matrix.platform }}' )"
1213+
echo "PUSH_IMAGE_REQUIRED=${PUSH_IMAGE_REQUIRED}"
1214+
echo "BUILD_IMAGE_REQUIRED=${BUILD_IMAGE_REQUIRED}"
11911215
} >> "${GITHUB_ENV}"
1216+
fi
11921217
11931218
- name: Build Stackql image with buildx
11941219
uses: docker/build-push-action@v6
1220+
if: env.BUILD_IMAGE_REQUIRED == 'true'
11951221
with:
11961222
context: .
11971223
build-args: |
@@ -1207,16 +1233,19 @@ jobs:
12071233

12081234
- name: Upload artifact
12091235
uses: actions/upload-artifact@v4
1236+
if: env.BUILD_IMAGE_REQUIRED == 'true'
12101237
with:
12111238
name: myimage-${{ env.IMAGE_PLATFORM_SAN }}
1212-
path: ${{ runner.temp }}/myimage-${{ env.IMAGE_PLATFORM_SAN }}
1239+
path: ${{ runner.temp }}/myimage-${{ env.IMAGE_PLATFORM_SAN }}.tar
12131240

12141241
- name: Load image
1242+
if: env.BUILD_IMAGE_REQUIRED == 'true'
12151243
run: |
12161244
docker load --input ${{ runner.temp }}/myimage-${{ env.IMAGE_PLATFORM_SAN }}.tar
12171245
docker image ls -a
12181246
12191247
- name: Debug info
1248+
if: env.BUILD_IMAGE_REQUIRED == 'true'
12201249
run: |
12211250
echo "psql version info: $(psql --version)"
12221251
echo ""
@@ -1252,13 +1281,13 @@ jobs:
12521281
echo ""
12531282
12541283
- name: Run robot mocked functional tests
1255-
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64'
1284+
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true'
12561285
timeout-minutes: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && 20 || vars.DEFAULT_STEP_TIMEOUT_MIN }}
12571286
run: |
12581287
python cicd/python/build.py --robot-test --config='{ "variables": { "EXECUTION_PLATFORM": "docker" } }'
12591288
12601289
- name: Run POSTGRES BACKEND robot mocked functional tests
1261-
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64'
1290+
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true'
12621291
timeout-minutes: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && 20 || vars.DEFAULT_STEP_TIMEOUT_MIN }}
12631292
run: |
12641293
echo "## Stray flask apps to be killed before robot tests ##"
@@ -1278,12 +1307,12 @@ jobs:
12781307
python cicd/python/build.py --robot-test --config='{ "variables": { "EXECUTION_PLATFORM": "docker", "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": true, "SQL_BACKEND": "postgres_tcp" } }'
12791308
12801309
- name: Output from mocked functional tests
1281-
if: always() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64'
1310+
if: always() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true'
12821311
run: |
12831312
cat ./test/robot/reports/output.xml
12841313
12851314
- name: Run robot integration tests
1286-
if: env.AZURE_CLIENT_SECRET != '' && startsWith(env.STATE_SOURCE_TAG, 'build-release') && matrix.platform == 'linux/amd64'
1315+
if: env.AZURE_CLIENT_SECRET != '' && startsWith(env.STATE_SOURCE_TAG, 'build-release') && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true'
12871316
env:
12881317
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
12891318
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}

0 commit comments

Comments
 (0)