Skip to content

Commit

Permalink
Merge branch 'latest' into slurmrestd
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort authored Apr 17, 2024
2 parents 9142f5c + 3756b82 commit 9f915be
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 107 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ updates:
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
groups:
actions-dependencies:
patterns:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/DockerBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build

on:
workflow_call:
inputs:
matrix:
type: string
required: true
description: "The strategy matrix used to build images"

jobs:
build:
name: Build Images
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix: ${{ fromJson(inputs.matrix) }}

steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
uses: docker/build-push-action@v5
with:
tags: ${{ matrix.image-tags }}
outputs: type=docker,dest=/tmp/image.tar
build-args: SLURM_VERSION=${{ matrix.slurm-version }}
cache-from: type=gha,scope=build-${{ github.ref_name }}-${{ matrix.slurm-version }}
cache-to: type=gha,mode=max,scope=build-${{ github.ref_name }}-${{ matrix.slurm-version }}

- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: slurm-${{ matrix.slurm-version }}
path: /tmp/image.tar
51 changes: 24 additions & 27 deletions .github/workflows/DockerPublish.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
name: Publish Docker Images
name: Publish

on:
release:
types: [ "released" ]
workflow_call:
inputs:
matrix:
type: string
required: true
description: "The strategy matrix used to build images"

jobs:
build:
name: Test Images
uses: ./.github/workflows/DockerTest.yml

publish:
runs-on: ubuntu-latest
name: Publish Images
needs: [ build ]

strategy:
fail-fast: false
matrix:
include:
- slurm-version: 20.02.5.1
tags: ghcr.io/${{ github.repository_owner }}/test-env:20.02.5.1

- slurm-version: 20.11.9.1
tags: ghcr.io/${{ github.repository_owner }}/test-env:20.11.9.1

- slurm-version: 22.05.2.1
tags: ghcr.io/${{ github.repository_owner }}/test-env:22.05.2.1

- slurm-version: 23.02.5.1
tags: ghcr.io/${{ github.repository_owner }}/test-env:23.02.5.1,ghcr.io/${{ github.repository_owner }}/test-env:latest
matrix: ${{ fromJson(inputs.matrix) }}

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Fetch image artifact
uses: actions/download-artifact@v4
with:
name: slurm-${{ matrix.slurm-version }}
path: /tmp

- name: Define Docker metadata
id: meta
uses: docker/metadata-action@v5
- name: Load image
run: docker load --input /tmp/image.tar

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -45,10 +34,18 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Define Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image-tags }}
labels: |
edu.pitt.crc.slurm-tag=${{ matrix.slurm-version }}
- name: Build and publish image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ matrix.tags }}
tags: ${{ matrix.image-tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: SLURM_VERSION=${{ matrix.slurm-version }}
47 changes: 23 additions & 24 deletions .github/workflows/DockerTest.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
name: Test Docker Images
name: Test

on:
workflow_call:
pull_request:
push:
branches: [ "latest" ]
inputs:
matrix:
type: string
required: true
description: "The strategy matrix used to build images"

jobs:
build:
test:
runs-on: ubuntu-latest
name: Test Images

strategy:
fail-fast: false
matrix:
slurm-version: [ "20.11.9", "22.05.2", "22.05.11", "23.02.5" ]
matrix: ${{ fromJson(inputs.matrix) }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
- name: Fetch image artifact
uses: actions/download-artifact@v4
with:
load: true
tags: test-image
build-args: SLURM_VERSION=${{ matrix.slurm-version }}
name: slurm-${{ matrix.slurm-version }}
path: /tmp

- name: Load image
run: docker load --input /tmp/image.tar

- name: Test container is restartable
run: |
docker container create --name rerun_test_container test-image
image_name="ghcr.io/pitt-crc/test-env:${{ matrix.slurm-version }}"
docker container create --name rerun_test_container $image_name
docker container start -i rerun_test_container
docker container start -i rerun_test_container
docker container rm rerun_test_container
- name: Run bats tests
run: docker run -i -v $(pwd)/tests:/tests test-image bats /tests

- name: Run tests
run: |
image_name="ghcr.io/pitt-crc/test-env:${{ matrix.slurm-version }}"
docker run -i -v $(pwd)/tests:/tests $image_name bats /tests
# Use this job for branch protection rules
report-test-status:
name: Report Test Status
runs-on: ubuntu-latest
needs: build
needs: test
if: always()
steps:
- name: Check build status
if: ${{ contains(needs.*.result, 'failure') }}
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled') }}
run: exit 1
26 changes: 26 additions & 0 deletions .github/workflows/Matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Matrix

on:
workflow_call:
outputs:
matrix:
description: "The strategy matrix used to build images"
value: ${{ jobs.matrix.outputs.matrix }}

jobs:
matrix:
name: Load Build Matrix
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.load-matrix.outputs.matrix }}

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Load matrix
id: load-matrix
uses: zoexx/github-action-json-file-properties@release
with:
file_path: ".github/workflows/matrix.json"
25 changes: 25 additions & 0 deletions .github/workflows/PullRequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pull Request

on:
pull_request:
push:
branches: [ "latest" ]

jobs:
matrix:
name: Matrix
uses: ./.github/workflows/Matrix.yml

build:
name: Build
needs: [ matrix ]
uses: ./.github/workflows/DockerBuild.yml
with:
matrix: ${{ needs.matrix.outputs.matrix }}

test:
name: Test
needs: [ matrix, build ]
uses: ./.github/workflows/DockerTest.yml
with:
matrix: ${{ needs.matrix.outputs.matrix }}
31 changes: 31 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
release:
types: [ "released" ]

jobs:
matrix:
name: Matrix
uses: ./.github/workflows/Matrix.yml

build:
name: Build
needs: [ matrix ]
uses: ./.github/workflows/DockerBuild.yml
with:
matrix: ${{ needs.matrix.outputs.matrix }}

test:
name: Test
needs: [ matrix, build ]
uses: ./.github/workflows/DockerTest.yml
with:
matrix: ${{ needs.matrix.outputs.matrix }}

publish:
name: Publish
needs: [ matrix, build, test ]
uses: ./.github/workflows/DockerPublish.yml
with:
matrix: ${{ needs.matrix.outputs.matrix }}
22 changes: 22 additions & 0 deletions .github/workflows/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"matrix": {
"include": [
{
"slurm-version": "20.11.9",
"image-tags": "ghcr.io/pitt-crc/test-env:20.11.9"
},
{
"slurm-version": "22.05.2",
"image-tags": "ghcr.io/pitt-crc/test-env:22.05.2"
},
{
"slurm-version": "22.05.11",
"image-tags": "ghcr.io/pitt-crc/test-env:22.05.11"
},
{
"slurm-version": "23.02.5",
"image-tags": "ghcr.io/pitt-crc/test-env:23.02.5,ghcr.io/pitt-crc/test-env:latest"
}
]
}
}
Loading

0 comments on commit 9f915be

Please sign in to comment.