Skip to content

Add common and harness specific configuration for deployment and publication #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3021b83
Add pre-commit config file
Feb 23, 2025
d25358a
Add dependabot config
Feb 23, 2025
c94e37d
Add license
Feb 23, 2025
c314b62
Add build workflow
Feb 24, 2025
f926fd4
Add automerge for dependabot PRs
Feb 24, 2025
be69588
Add missing bracket
Feb 24, 2025
a96b3d3
Correct quotes
Feb 24, 2025
7dbe4b1
Remove dotnet condition
Feb 24, 2025
71a9c4c
Remove --from when installing bowtie
Feb 24, 2025
8afc66e
Use correct package to install bowtie
Feb 24, 2025
ea9853a
Version is always set in the matrix
Feb 24, 2025
cd85920
Try extract version from latest and current version and prepare a the…
Feb 27, 2025
c427f39
Move part of tags to build image step
Feb 27, 2025
a1b573a
Print collected versions
Feb 27, 2025
3214f25
Execute pre-commit hook
Feb 27, 2025
b852abd
Use raw value in jq to get rid of quotes
Feb 27, 2025
5a1e33d
Trigger image build only on a push to main branch
Feb 27, 2025
550260a
Correct which version is used for a tag
Feb 27, 2025
5970ae4
Add tag with version to the final image
Feb 27, 2025
2bd10c6
Use gh cli to create tag and release
Feb 28, 2025
76dd912
Add missing GH_TOKEN env variable
Feb 28, 2025
37e94bb
Use personal access token to create a tag and release
Feb 28, 2025
9217c0c
Use default github token for release creation
Feb 28, 2025
81750f1
Use bowtie action
Mar 7, 2025
401d87b
Add workflow to rebuild all available old version and the latest one …
OptimumCode Mar 8, 2025
ca0a56b
Add zizmor pre-commit hook and update workflow to comply with zizmor …
OptimumCode Mar 8, 2025
9f1969b
Cleanup workflows
Mar 10, 2025
8ecb6b5
Use user.login to identify whether the PR is from dependabot
Mar 11, 2025
751f7d4
Remove manual tag creation. Use release API to create a tag
Mar 11, 2025
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
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
# common configuration
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"

# test harnsess configuration
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
186 changes: 186 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Rebuild Bowtie Image

on:
workflow_dispatch:
pull_request:
push:
branches-ignore:
- "wip*"

env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}

concurrency:
group: images-${{ github.ref }}
cancel-in-progress: true

jobs:
meta:
runs-on: ubuntu-latest
outputs:
latest-version: ${{ steps.version.outputs.value }}
implementation-name: ${{ steps.impl.outputs.name }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Compute implementation name
id: impl
run: echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT

- name: Compute latest implementation version
id: version
run: |
version=$(uvx --from 'bowtie-json-schema' --python 3.13 bowtie info \
--implementation ${{ steps.impl.outputs.name }} \
--format json | jq -r '.version // empty')
echo "value=${version}" >> $GITHUB_OUTPUT

build:
needs: meta

runs-on: ubuntu-latest

outputs:
current-version: ${{ steps.current-version.outputs.value }}

permissions:
id-token: write
contents: read
attestations: write
packages: write

steps:
- uses: actions/checkout@v4

- name: Install qemu
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static

- name: Build
id: build_image
uses: redhat-actions/buildah-build@v2
with:
context: '.'
containerfiles: |
Dockerfile
image: ${{ needs.meta.outputs.implementation-name }}
tags: ${{ github.sha }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }}
archs: amd64, arm64

- name: Set DOCKER_HOST so podman-built images are findable
run: |
systemctl --user enable --now podman.socket
sudo loginctl enable-linger $USER
podman --remote info
echo "DOCKER_HOST=unix://$(podman info --format '{{.Host.RemoteSocket.Path}}')" >> $GITHUB_ENV

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Smoke Test
run: |
uvx --from 'bowtie-json-schema' --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format json
uvx --from 'bowtie-json-schema' --python 3.13 bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format markdown >> $GITHUB_STEP_SUMMARY

- name: Collect current version
id: current-version
run: |
version=$(uvx --from 'bowtie-json-schema' --python 3.13 bowtie info \
--implementation "localhost/${{ steps.build_image.outputs.image-with-tag }}" \
--format json | jq -r '.version // empty')
echo "value=${version}" >> $GITHUB_OUTPUT

- name: Print collected versions
run: echo "latest_version=${{ needs.meta.outputs.latest-version }}; current_version=${{ steps.current-version.outputs.value }}"

- name: Log in to ghcr.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ${{ env.IMAGE_REGISTRY }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

- name: Add tag with version to the image
run: podman tag ${{ steps.build_image.outputs.image-with-tag }} ${{ steps.build_image.outputs.image }}:${{ steps.current-version.outputs.value }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

- name: Publish
id: push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.current-version.outputs.value }} ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

- name: Generate attestation for images
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

mark-previous-version:
needs: [build, meta]
runs-on: ubuntu-latest

if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build.outputs.current-version != needs.meta.outputs.latest-version

env:
TAG: v${{ needs.meta.outputs.latest-version }}
COMMIT: ${{ github.event.before }}
GH_TOKEN: ${{ secrets.PAT_GITHUB }}

steps:

- name: Create a tag to mark previous latest version
env:
COMMIT: ${{ env.COMMIT }}
run: >
gh api
--method POST
-H "Accept: application/vnd.github+json"
-H "X-GitHub-Api-Version: 2022-11-28"
/repos/${{ github.repository }}/git/refs
-f "ref=refs/tags/$TAG"
-f "sha=$COMMIT"

- name: Create release assotiated with the tag
run: >
gh api
--method POST
-H "Accept: application/vnd.github+json"
-H "X-GitHub-Api-Version: 2022-11-28"
/repos/${{ github.repository }}/releases
-f "tag_name=$TAG"
-f "name=$TAG"
-f "body=Automatic release for $TAG"
-F "generate_release_notes=true"


automerge:
needs: build
runs-on: ubuntu-latest

if: (!cancelled() && github.event_name == 'pull_request' && github.actor == 'dependabot[bot]')

permissions:
contents: write
pull-requests: write

steps:
- name: Automatically merge allowed PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
# common hooks - should be added to template project
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix, lf]
- id: trailing-whitespace

# test harness specific hooks
- repo: https://github.com/dustinsand/pre-commit-jvm
rev: v0.11.0
hooks:
- name: ktlint (java/kotlin implementations)
id: ktlint
args: [--format]
- name: detekt (java/kotlin implementations)
id: detekt
args: ["--build-upon-default-config"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) 2022 Bowtie's Authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Bowtie's logo was designed by @PaulWaller with work sponsored by [endjin](https://endjin.com).
Loading