-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: use separate github workflows to depend on the same dependency im…
…age for tests and linter
- Loading branch information
Showing
4 changed files
with
102 additions
and
146 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Dependency Image | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
dependencyImage: | ||
name: Build Docker Image Dependencies | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Generate dependency files hash | ||
id: files-hash | ||
run: | | ||
DIR_HASH=$(echo -n ${{ hashFiles('conanfile.py', 'conanprofile.docker', '.github/workflows/ci.yml', './Dockerfile_dependencies') }}) | ||
echo "DIR_HASH=$DIR_HASH" >> $GITHUB_ENV | ||
- name: Docker metadata | ||
id: dockerMetadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||
type=raw,value=${{ env.DIR_HASH }} | ||
type=sha,format=long,prefix=commit- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check if image exists | ||
id: check-image | ||
run: | | ||
EXISTS=$(docker manifest inspect ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} > /dev/null 2>&1 && echo "true" || echo "false") | ||
echo "CACHE_HIT=$EXISTS" >> $GITHUB_ENV | ||
- name: Set up Docker Buildx | ||
if: env.CACHE_HIT == 'false' | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push image if input files changed | ||
if: env.CACHE_HIT == 'false' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: Dockerfile_dependencies | ||
push: true | ||
tags: ${{ steps.dockerMetadata.outputs.tags }} | ||
cache-from: type=gha,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }} | ||
cache-to: type=gha,mode=min,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }} | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Retag and push existing image if cache hit | ||
if: env.CACHE_HIT == 'true' | ||
run: | | ||
TAGS=(${{ steps.dockerMetadata.outputs.tags }}) | ||
for TAG in "${TAGS[@]}"; do | ||
docker buildx imagetools create --tag $TAG ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Formatting | ||
on: | ||
push: | ||
|
||
jobs: | ||
formatting-check: | ||
name: Formatting Check | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
path: | ||
- check: 'src' | ||
- check: 'include' | ||
exclude: '(PerfEvent.hpp)' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run clang-format style check | ||
uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: '17' | ||
check-path: ${{ matrix.path['check'] }} | ||
exclude-regex: ${{ matrix.path['exclude'] }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
name: LAPIS-SILO | ||
|
||
on: | ||
push: | ||
workflow_run: | ||
workflows: [ "Dependency Image" ] | ||
types: | ||
- completed | ||
|
||
|
||
concurrency: | ||
group: ci-${{ github.ref }} | ||
|
@@ -12,90 +16,9 @@ env: | |
DOCKER_IMAGE_NAME: ghcr.io/genspectrum/lapis-silo | ||
|
||
jobs: | ||
formatting-check: | ||
name: Formatting Check | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
path: | ||
- check: 'src' | ||
- check: 'include' | ||
exclude: '(PerfEvent.hpp)' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run clang-format style check | ||
uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: '17' | ||
check-path: ${{ matrix.path['check'] }} | ||
exclude-regex: ${{ matrix.path['exclude'] }} | ||
|
||
dependencyImage: | ||
name: Build Docker Image Dependencies | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Generate dependency files hash | ||
id: files-hash | ||
run: | | ||
DIR_HASH=$(echo -n ${{ hashFiles('conanfile.py', 'conanprofile.docker', '.github/workflows/ci.yml', './Dockerfile_dependencies') }}) | ||
echo "DIR_HASH=$DIR_HASH" >> $GITHUB_ENV | ||
- name: Docker metadata | ||
id: dockerMetadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=branch | ||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||
type=raw,value=${{ env.DIR_HASH }} | ||
type=sha,format=long,prefix=commit- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check if image exists | ||
id: check-image | ||
run: | | ||
EXISTS=$(docker manifest inspect ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} > /dev/null 2>&1 && echo "true" || echo "false") | ||
echo "CACHE_HIT=$EXISTS" >> $GITHUB_ENV | ||
- name: Set up Docker Buildx | ||
if: env.CACHE_HIT == 'false' | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push image if input files changed | ||
if: env.CACHE_HIT == 'false' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: Dockerfile_dependencies | ||
push: true | ||
tags: ${{ steps.dockerMetadata.outputs.tags }} | ||
cache-from: type=gha,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }} | ||
cache-to: type=gha,mode=min,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }} | ||
platforms: linux/amd64,linux/arm64 | ||
|
||
- name: Retag and push existing image if cache hit | ||
if: env.CACHE_HIT == 'true' | ||
run: | | ||
TAGS=(${{ steps.dockerMetadata.outputs.tags }}) | ||
for TAG in "${TAGS[@]}"; do | ||
docker buildx imagetools create --tag $TAG ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} | ||
done | ||
dockerImageUnitTests: | ||
name: Build Docker Image and Run Unit Tests | ||
runs-on: ubuntu-latest | ||
needs: dependencyImage | ||
permissions: | ||
packages: write | ||
steps: | ||
|
@@ -176,7 +99,7 @@ jobs: | |
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}" | ||
|
||
- name: npm install | ||
run: cd endToEndTests && npm ci | ||
|