Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: Build / Test / Push

on:
push:
branches:
- '**'
workflow_dispatch:

env:
BUILD_SUFFIX: -build-${{ github.run_id }}_${{ github.run_attempt }}
DOCKER_METADATA_SET_OUTPUT_ENV: 'true'

jobs:
build:
runs-on: ${{ matrix.runner }}
outputs:
image-arm64: ${{ steps.gen-output.outputs.image-arm64 }}
image-x64: ${{ steps.gen-output.outputs.image-x64 }}
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: build-meta
name: Docker meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: type=sha,suffix=${{ env.BUILD_SUFFIX }}

# Build cache is shared among all builds of the same architecture
- id: cache-meta
name: Docker meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: type=raw,value=buildcache-${{ runner.arch }}

- id: get-registry
name: Get the sanitized registry name
run: |
echo "registry=$(echo '${{ steps.build-meta.outputs.tags }}' | cut -f1 -d:)" | tee -a "$GITHUB_OUTPUT"

- id: build
name: Build/push the arch-specific image
uses: docker/build-push-action@v6
with:
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
labels: ${{ steps.build-meta.outputs.labels }}
provenance: mode=max
sbom: true
tags: ${{ steps.get-registry.outputs.registry }}
outputs: type=image,push-by-digest=true,push=true

- id: gen-output
name: Write arch-specific image digest to outputs
run: |
echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"

merge:
runs-on: ubuntu-24.04
needs: build
env:
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.image-arm64 }}
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.image-x64 }}
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: meta
name: Generate tag for the app image
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: type=sha,suffix=${{ env.BUILD_SUFFIX }}

- name: Push the multi-platform app image
run: |
docker buildx imagetools create \
--tag "$DOCKER_METADATA_OUTPUT_TAGS" \
"$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64"

test:
runs-on: ubuntu-24.04
needs: merge
env:
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.image }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Compose
uses: docker/setup-compose-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup the stack
run: |
docker compose build --quiet
docker compose pull --quiet
docker compose up --wait
docker compose exec -u root app chown -R alma:alma artifacts

- name: Run RSpec
if: ${{ always() }}
run: |
docker compose exec -e RAILS_ENV=test app rspec --format progress --format html --out artifacts/rspec.html

- name: Copy out artifacts
if: ${{ always() }}
run: |
docker compose cp app:/opt/app/artifacts ./
docker compose logs > artifacts/docker-compose-services.log
docker compose config > artifacts/docker-compose.merged.yml

- name: Upload the test report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: Gobi Build Report (${{ github.run_id }}_${{ github.run_attempt }})
path: artifacts/*
if-no-files-found: error

push:
runs-on: ubuntu-24.04
needs:
- merge
- test
env:
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.image }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Produce permanent image tags
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=sha
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Retag and push the image
run: |
docker pull "$DOCKER_APP_IMAGE"
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE"
docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)"
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Push Release Tags

on:
push:
tags:
- '**'
workflow_dispatch:

env:
DOCKER_METADATA_SET_OUTPUT_ENV: 'true'

jobs:
retag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine the sha-based image tag to retag
id: get-base-image
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: type=sha

- name: Verify that the image was previously built
env:
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
run: |
docker pull "$BASE_IMAGE"

- name: Produce release tags
id: tag-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: latest=false
tags: |
type=ref,event=tag
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}

- name: Retag the pulled image
env:
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
run: |
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$BASE_IMAGE"
docker push --all-tags "$(echo "$BASE_IMAGE" | cut -f1 -d:)"
24 changes: 14 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GEM
cucumber (>= 4.0, < 8.0)
rspec-expectations (~> 3.4)
thor (~> 1.0)
ast (2.4.2)
ast (2.4.3)
builder (3.2.4)
childprocess (4.1.0)
contracts (0.17)
Expand Down Expand Up @@ -59,13 +59,15 @@ GEM
multi_test (0.1.2)
nokogiri (1.13.3-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.2.0)
parallel (1.27.0)
parser (3.3.10.0)
ast (~> 2.4.1)
racc
prism (1.6.0)
racc (1.6.0)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.3.0)
regexp_parser (2.11.3)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
Expand All @@ -82,7 +84,7 @@ GEM
rspec-support (3.11.0)
rspec_junit_formatter (0.5.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.27.0)
rubocop (1.26.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
Expand All @@ -91,21 +93,23 @@ GEM
rubocop-ast (>= 1.16.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.17.0)
parser (>= 3.1.1.0)
rubocop-ast (1.48.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-checkstyle_formatter (0.5.0)
rubocop (>= 1.14.0)
ruby-progressbar (1.11.0)
ruby-progressbar (1.13.0)
scrub_rb (1.0.1)
sys-uname (1.2.2)
ffi (~> 1.1)
thor (1.2.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unicode-display_width (2.1.0)
unicode-display_width (2.6.0)

PLATFORMS
aarch64-linux
x86_64-linux

DEPENDENCIES
Expand All @@ -118,7 +122,7 @@ DEPENDENCIES
rake
rspec
rspec_junit_formatter
rubocop
rubocop (~> 1.26.0)
rubocop-checkstyle_formatter
thor (~> 1.1)

Expand Down
15 changes: 0 additions & 15 deletions Jenkinsfile

This file was deleted.

9 changes: 9 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
app:
build: !reset
image: ${DOCKER_APP_IMAGE}
volumes: !override
- artifacts:/opt/app/artifacts

volumes:
artifacts:
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
services:
gobi:
app:
build: .
command: watch --interval 600
image: containers.lib.berkeley.edu/lap/gobi/development:latest
init: yes
volumes:
- ./:/opt/app:rw
Expand Down