Dockerfile tests #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dockerfile tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
paths: | |
- '**/Dockerfile' | |
schedule: | |
- cron: '23 2 * * 0' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
define_changed_dockerfile_matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.changed-dockerfiles.outputs.all_changed_files }} | |
steps: | |
- uses: actions/checkout@v4 | |
- | |
name: Get Changed Dockerfiles | |
id: changed-dockerfiles | |
uses: tj-actions/changed-files@v44 | |
with: | |
matrix: true | |
files: '**/Dockerfile' | |
files_ignore: '**/GlimpseImputationPipeline/glimpse_docker/Dockerfile' | |
- name: List dockerfiles | |
run: echo '${{ steps.changed-dockerfiles.outputs.all_changed_files}}' | |
define_all_dockerfile_matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.all-dockerfiles.outputs.files}} | |
steps: | |
- uses: actions/checkout@v4 | |
- | |
name: Get all Dockerfiles | |
id: all-dockerfiles | |
run: | | |
{ | |
echo 'files<<EOF' | |
find . -name "Dockerfile" ! -path "*/GlimpseImputationPipeline/glimpse_docker/*" | jq -R . | jq -s . | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
- name: List dockerfiles | |
run: echo '${{ steps.all-dockerfiles.outputs.files}}' | |
test_builds: | |
runs-on: ubuntu-latest | |
needs: [define_changed_dockerfile_matrix, define_all_dockerfile_matrix] | |
strategy: | |
matrix: | |
dockerfile: ${{ github.ref != 'refs/heads/main' && fromJSON(needs.define_changed_dockerfile_matrix.outputs.matrix) || fromJSON(needs.define_all_dockerfile_matrix.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- | |
name: Get context | |
id: get-context | |
run: | | |
echo "context=$(dirname ${{ matrix.dockerfile }})" >> $GITHUB_OUTPUT | |
- | |
name: Build | |
uses: docker/build-push-action@v6 | |
with: | |
context: ${{ steps.get-context.outputs.context }} | |
file: ${{ matrix.dockerfile }} | |
test_glimpse_docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- | |
name: Check if Dockerfile has changed | |
id: check-if-changed | |
if: ${{ github.ref != 'refs/heads/main' }} | |
uses: tj-actions/changed-files@v44 | |
with: | |
files: '**/GlimpseImputationPipeline/glimpse_docker/Dockerfile' | |
- | |
name: Build main GLIMPSE Docker | |
if: ${{ github.ref == 'refs/heads/main' || steps.check-if-changed.outputs.all_changed_files_count > 0 }} | |
run: | | |
cd GlimpseImputationPipeline/glimpse_docker | |
./build_base_and_extension_docker.sh -r https://github.com/odelaneau/GLIMPSE.git -t test -b master -y | |
- | |
name: Build Extract Num Sites Docker | |
if: ${{ github.ref == 'refs/heads/main' || steps.check-if-changed.outputs.all_changed_files_count > 0 }} | |
run: | | |
cd GlimpseImputationPipeline/glimpse_docker | |
./build_extract_num_sites_from_reference_chunk_docker.sh -y -r https://github.com/michaelgatzen/GLIMPSE.git -t test -b master | |