Skip to content

Commit a7cbf7e

Browse files
committed
CI fill
1 parent 8942bf1 commit a7cbf7e

File tree

12 files changed

+346
-211
lines changed

12 files changed

+346
-211
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
version: 2
3+
updates:
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: github-actions
6+
directory: /
7+
schedule:
8+
interval: monthly
9+
groups:
10+
gha-dependencies:
11+
patterns:
12+
- '*'

.github/workflows/build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: Build images and upload them to ghcr.io
3+
4+
env:
5+
BUILDKIT_PROGRESS: plain
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
runsOn:
11+
description: GitHub Actions Runner image
12+
required: true
13+
type: string
14+
platforms:
15+
description: Target platforms for the build (linux/amd64 and/or linux/arm64)
16+
required: true
17+
type: string
18+
outputs:
19+
image:
20+
description: Image identified by digests
21+
value: ${{ jobs.build.outputs.image }}
22+
23+
jobs:
24+
build:
25+
name: ${{ inputs.platforms }}
26+
runs-on: ${{ inputs.runsOn }}
27+
timeout-minutes: 120
28+
29+
outputs:
30+
image: ${{ steps.bake_metadata.outputs.image }}
31+
32+
# Make sure we fail if any command in a piped command sequence fails
33+
defaults:
34+
run:
35+
shell: bash -e -o pipefail {0}
36+
37+
steps:
38+
39+
- name: Checkout Repo ⚡️
40+
uses: actions/checkout@v4
41+
42+
- name: Set up QEMU
43+
if: ${{ inputs.platforms != 'linux/amd64' }}
44+
uses: docker/setup-qemu-action@v3
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Login to GitHub Container Registry 🔑
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Build and upload to ghcr.io 📤
57+
id: build-upload
58+
uses: docker/bake-action@v4
59+
with:
60+
push: true
61+
# Using provenance to disable default attestation so it will build only desired images:
62+
# https://github.com/orgs/community/discussions/45969
63+
provenance: false
64+
set: |
65+
*.platform=${{ inputs.platforms }}
66+
*.output=type=registry,push-by-digest=true,name-canonical=true
67+
*.cache-to=type=gha,scope=${{ github.workflow }},mode=max
68+
*.cache-from=type=gha,scope=${{ github.workflow }}
69+
files: |
70+
docker-bake.hcl
71+
build.json
72+
73+
- name: Set output variables
74+
id: bake_metadata
75+
run: |
76+
.github/workflows/extract-image-name.sh | tee -a "${GITHUB_OUTPUT}"
77+
env:
78+
BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }}

.github/workflows/ci.yml

Lines changed: 0 additions & 158 deletions
This file was deleted.

.github/workflows/env.hcl

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/extract-image-name.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
# The input to this script is a JSON string passed via BAKE_METADATA env variable
66
# Here's example input (trimmed to relevant bits):
77
# BAKE_METADATA: {
8-
# "base": {
8+
# "python": {
99
# "containerimage.descriptor": {
1010
# "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
1111
# "digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d",
1212
# "size": 6170,
1313
# },
1414
# "containerimage.digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d",
15-
# "image.name": "ghcr.io/pspgen/quantum-espresso"
15+
# "image.name": "ghcr.io/cnts4sci/python"
1616
# }
1717
# }
1818
#
1919
# Example output (real output is on one line):
2020
#
21-
# image="ghcr.io/pspgen/quantum-espresso@sha256:79a0f984b9e03b733304fda809ad3e8eec8416992ff334052d75da00cadb8f12"
21+
# image="ghcr.io/cnts4sci/python@sha256:79a0f984b9e03b733304fda809ad3e8eec8416992ff334052d75da00cadb8f12"
2222
# }
2323
#
2424
# This json output is later turned to environment variables using fromJson() GHA builtin
25-
# (e.g. BUILD_MACHINE_IMAGE=ghcr.io/pspgen/quantum-espresso@sha256:8e57a52b...)
25+
# (e.g. BUILD_MACHINE_IMAGE=ghcr.io/cnts4sci/python@sha256:8e57a52b...)
2626
# and these are in turn read in the docker-compose.<target>.yml files for tests.
2727

2828
if [[ -z ${BAKE_METADATA-} ]];then

.github/workflows/main.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
name: Docker
3+
4+
on:
5+
pull_request:
6+
paths-ignore:
7+
- "**.md"
8+
- ruff.toml
9+
- bumpver.toml
10+
- .pre-commit-config.yaml
11+
push:
12+
branches:
13+
- main
14+
tags:
15+
- "v*"
16+
workflow_dispatch:
17+
18+
# https://docs.github.com/en/actions/using-jobs/using-concurrency
19+
concurrency:
20+
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
env:
25+
FORCE_COLOR: 1
26+
27+
jobs:
28+
29+
build-amd64:
30+
uses: ./.github/workflows/build.yml
31+
with:
32+
runsOn: ubuntu-22.04
33+
platforms: linux/amd64
34+
35+
test-amd64:
36+
needs: build-amd64
37+
strategy:
38+
fail-fast: false
39+
uses: ./.github/workflows/test.yml
40+
with:
41+
runsOn: ubuntu-22.04
42+
image: ${{ needs.build-amd64.outputs.image }}
43+
integration: false
44+
45+
build:
46+
needs: test-amd64
47+
uses: ./.github/workflows/build.yml
48+
with:
49+
runsOn: ubuntu-22.04
50+
platforms: linux/amd64,linux/arm64
51+
52+
# To save arm64 runner resources, we run the tests only on main
53+
# and only for full-stack image (same for integration tests below).
54+
test-arm64:
55+
if: >-
56+
github.repository == 'cnts4sci/build-machine'
57+
&& (github.ref_type == 'tag' || github.ref_name == 'main')
58+
needs: build
59+
uses: ./.github/workflows/test.yml
60+
with:
61+
runsOn: buildjet-4vcpu-ubuntu-2204-arm
62+
image: ${{ needs.build.outputs.image }}
63+
integration: false
64+
65+
test-integration:
66+
name: Integration tests
67+
needs: build
68+
strategy:
69+
fail-fast: false
70+
# Trick to exclude arm64 tests from PRs
71+
# https://github.com/orgs/community/discussions/26253
72+
matrix:
73+
runner: [ubuntu-22.04, buildjet-4vcpu-ubuntu-2204-arm]
74+
isPR:
75+
- ${{ github.event_name == 'pull_request' }}
76+
exclude:
77+
- isPR: true
78+
runner: buildjet-4vcpu-ubuntu-2204-arm
79+
80+
uses: ./.github/workflows/test.yml
81+
with:
82+
runsOn: ${{ matrix.runner }}
83+
image: ${{ needs.build.outputs.image }}
84+
integration: true
85+
86+
publish-ghcr:
87+
needs: [build, test-amd64]
88+
uses: ./.github/workflows/publish.yml
89+
with:
90+
runsOn: ubuntu-22.04
91+
image: ${{ needs.build.outputs.image }}
92+
registry: ghcr.io
93+
secrets: inherit
94+

0 commit comments

Comments
 (0)