Skip to content

Commit

Permalink
workflow/pull_request.yml: Split up setup and move build base image t…
Browse files Browse the repository at this point in the history
…o separate job
  • Loading branch information
jo-basevi committed Sep 27, 2024
1 parent 344637c commit 06b8986
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
name: Build and test conda env
on: pull_request

on:
pull_request:
branches:
- 'main'

jobs:
generate_matrix:
uses: ./.github/workflows/get_changed_env.yml
setup:

build_base_image:
runs-on: ubuntu-latest
needs: generate_matrix
if: ${{ needs.generate_matrix.outputs.matrix != '{"include":[]}' }}
container:
image: quay.io/singularity/singularity:v3.11.4
options: --privileged
environment: Gadi
outputs:
built-container: ${{ steps.changed-container-def.outputs.any_changed }}
steps:
- name: Checkout repository
### Latest at time of writing
uses: actions/checkout@v4

- name: Check if container definition has changed
id: changed-container-def
uses: tj-actions/changed-files@v41
uses: tj-actions/changed-files@48d8f15b2aaa3d255ca5af3eba4870f807ce6b3c # v43.0.2
with:
files_yaml: |
containerdef:
- container/container.def
files: |
- container/container.def
- name: Build container if definition has changed
if: steps.changed-container-def.outputs.containerdef_any_changed == 'true'
if: steps.changed-container-def.outputs.any_changed == 'true'
run: |
echo ${{ needs.generate_matrix.outputs.matrix }}
sudo -E singularity build container/base.sif container/container.def
- name: Upload base container
if: steps.changed-container-def.outputs.any_changed == 'true'
uses: actions/upload-artifact@v4
with:
name: base-container
path: container/base.sif

setup:
runs-on: ubuntu-latest
needs: [ generate_matrix, build_base_image ]
if: ${{ needs.generate_matrix.outputs.matrix != '{"include":[]}' }}
environment: Gadi
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download base container
if: needs.build_base_image.outputs.built-container == 'true'
uses: actions/download-artifact@v4
with:
name: base-container
path: container

- name: Setup SSH
uses: access-nri/actions/.github/actions/setup-ssh@main
id: ssh
Expand All @@ -49,12 +77,10 @@ jobs:
- name: Create Admin dirs on Gadi
run: |
ssh ${{ secrets.USER }}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
source ${{ secrets.REPO_PATH }}/scripts/install_config.sh
source ${{ secrets.REPO_PATH }}/scripts/functions.sh
mkdir -p $ADMIN_DIR $JOB_LOG_DIR $BUILD_STAGE_DIR
set_admin_perms $ADMIN_DIR $JOB_LOG_DIR $BUILD_STAGE_DIR
EOT
build:
Expand Down

0 comments on commit 06b8986

Please sign in to comment.