Skip to content

Commit

Permalink
Fix/reworked ci (#100)
Browse files Browse the repository at this point in the history
* I am so confused

* Ok, if this doesn't work, we just need three workflows

* Don't think I need to do this, but who knows

* We've done a lot

* Dug

* Ok, hold on

* Let's try this

* Thoroughly confused

* Ok, hold on

* Ok, we can probably skip wider ruff formatting for now

* Do we need this now? I forget

* We probably need this

* I don't get it

* Is this a local thing?

* Our CI is gooderer

* Don't need that
  • Loading branch information
AidanHilt authored Jul 8, 2024
1 parent 73a152b commit 4efb3e0
Show file tree
Hide file tree
Showing 43 changed files with 1,151 additions and 1,785 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/atils-on-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Atils Build and Publish

on:
push:
branches:
- master
paths:
- 'atils/**'
- '.github/workflows/atils-run-ci.yaml'

jobs:
build-and-publish-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get atils version
run: echo "VERSION=$(grep -E '^version = "' atils/pyproject.toml | cut -d'"' -f2)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and publish atils image
uses: docker/build-push-action@v6
with:
push: true
file: atils/Dockerfile
context: atils
tags: |
aidanhilt/atils:${{ env.VERSION }}
aidanhilt/atils:latest
platforms: linux/amd64, linux/arm64

build-and-publish-python-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup python with pyproject.toml-specified version
uses: actions/setup-python@v5
with:
python-version-file: 'atils/pyproject.toml'
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install -n -vv
working-directory: atils
- name: Build and publish package to PyPI
run: |
poetry config pypi-token.pypi $PYPI_API_TOKEN
poetry build
poetry publish -n -vv
working-directory: atils
env:
PYPI_API_TOKEN: ${{ secrets.ATILS_PYPI_TOKEN }}
39 changes: 0 additions & 39 deletions .github/workflows/atils-run-ci.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/custom-containers-local-build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This is just an action we use to run local build+pushes
on:
workflow_dispatch:
inputs:
image:
description: "The directory name of the custom image to build"
tags:
description: "The tags to push to our repo"

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and publish custom image
uses: docker/build-push-action@v6
with:
push: true
file: custom-images/${{ inputs.image }}/Dockerfile
context: custom-images/${{ inputs.image }}
tags: ${{ inputs.tags }}
platforms: linux/amd64, linux/arm64
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '!custom-images/docs/**'

jobs:
find-out-changes:
generate-matrix:
runs-on: ubuntu-latest
outputs:
changed_directories: ${{ steps.set-output.outputs.changed_directories }}
Expand All @@ -35,39 +35,42 @@ jobs:

build-and-publish:
runs-on: ubuntu-latest
if: ${{ needs.find-out-changes.outputs.changed_directories != '' }}
if: ${{ needs.generate-matrix.outputs.changed_directories != '' }}
strategy:
matrix: ${{fromJson(needs.find-out-changes.outputs.changed_directories)}}
matrix: ${{ fromJson(needs.generate-matrix.outputs.changed_directories) }}
needs:
- find-out-changes
container:
image: aidanhilt/atils-ci:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- generate-matrix
steps:
- uses: actions/checkout@v3
- name: Get image repo
run: |
source ${{ matrix.dir }}/config.env
echo "REPO=$IMAGE_NAME" >> $GITHUB_ENV
- name: Get image tag
run: |
source ${{ matrix.dir }}/config.env
echo "TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Get image directory basename
run: |
NAME=$(basename ${{ matrix.dir }})
echo "NAME=$NAME" >> $GITHUB_ENV

- name: Set up QEMU
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}


- name: Check for .atils_buildconfig.json
id: check-buildconfig
run: |
if [ ! -f "${{ matrix.dir }}/.atils_buildconfig.json" ]; then
echo "No .atils_buildconfig.json found in ${{ matrix.dir }}. Exiting with failure."
exit 1
fi
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and publish custom image
if: steps.check-buildconfig.outcome == 'success'
run: |
atils build --build-directory "${{ matrix.dir }}" --action-set ci-build-publish
uses: docker/build-push-action@v6
with:
push: true
file: custom-images/${{ env.NAME }}/Dockerfile
context: custom-images/${{ env.NAME }}
tags: |
${{ env.REPO }}:${{ env.TAG }}
${{ env.REPO }}:latest
platforms: linux/amd64, linux/arm64
72 changes: 72 additions & 0 deletions .github/workflows/custom-containers-on-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Custom Images on Push to Branch

on:
push:
branches:
- '!master'
paths:
- 'custom-images/**'
- '.github/workflows/custom-containers-run-ci.yaml'
- '!custom-images/docs/**'

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
changed_directories: ${{ steps.set-output.outputs.changed_directories }}
steps:
- uses: actions/checkout@v3

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42.0.7
with:
dir_names: true
json: true
quotepath: false
dir_names_exclude_current_dir: true
files: |
custom-images/**
!custom-images/docs/**
- name: Set matrix-formatted output
id: set-output
run: echo "changed_directories={\"dir\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT"

build-and-publish:
runs-on: ubuntu-latest
if: ${{ needs.generate-matrix.outputs.changed_directories != '' }}
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.changed_directories) }}
needs:
- generate-matrix
steps:
- uses: actions/checkout@v3
- name: Get current branch
run: echo "BRANCH=$(echo ${GITHUB_REF#refs/*/} | tr / -)" >> $GITHUB_ENV
- name: Get image repo
run: |
source ${{ matrix.dir }}/config.env
echo "REPO=$IMAGE_NAME" >> $GITHUB_ENV
- name: Get image directory basename
run: |
NAME=$(basename ${{ matrix.dir }})
echo "NAME=$NAME" >> $GITHUB_ENV
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and publish custom image
uses: docker/build-push-action@v6
with:
push: true
file: custom-images/${{ env.NAME }}/Dockerfile
context: custom-images/${{ env.NAME }}
tags: "${{ env.REPO }}:${{ env.BRANCH }}"
platforms: linux/amd64, linux/arm64
83 changes: 0 additions & 83 deletions .github/workflows/helm-chart-run-ci.yaml

This file was deleted.

Loading

0 comments on commit 4efb3e0

Please sign in to comment.