From de12dc76601fe9df54af4a554758f85c83a7dcdb Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Fri, 11 Oct 2024 10:57:49 +0100 Subject: [PATCH] switch template to github --- .copier-answers.yml | 7 ++- .github/dependabot.yml | 8 +++ .github/workflows/build.yml | 113 ++++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 47 --------------- .gitlab/kanikobuild.sh | 29 --------- README.md | 4 +- 6 files changed, 127 insertions(+), 81 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build.yml delete mode 100644 .gitlab-ci.yml delete mode 100644 .gitlab/kanikobuild.sh diff --git a/.copier-answers.yml b/.copier-answers.yml index 795a983..707a05d 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,8 @@ _commit: 4.0.1 _src_path: gh:epics-containers/ioc-template description: A Generic IOC for andor3 cameras -git_platform: gitlab.diamond.ac.uk -name: ioc-andor3 -repo_uri: git@gitlab.diamond.ac.uk:controls/containers/iocs/ioc-andor3.git +git_platform: github.com +github_org: epics-containers +name: ioc-adandor3 +repo_uri: git@github.com:epics-containers/ioc-adandor3 rtems: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b9e8b67 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +# Look for updates to python and docker dependencies. + +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d0f115c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,113 @@ +name: Build and publish image to ghcr.io/epics-containers + +on: + push: + pull_request: + +jobs: + build: + # pull requests are a duplicate of a branch push if within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + epics-target: [linux-x86_64] # , linux-aarch64] + include: + - os: ubuntu-latest # everyone is on ubuntu-latest + - epics-target: linux-x86_64 + extension: "" + platform: linux/amd64 + + # # a temporary name until multi-arch is supported + # - epics-target: linux-aarch64 + # extension: -native-aarch64 + # platform: linux/arm64 + + runs-on: ${{ matrix.os }} + env: + TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}${{ matrix.extension }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io/${{ github.repository_owner }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{ matrix.platform }} + target: runtime + build-args: | + IMAGE_EXT=${{ matrix.extension }} + cache-from: type=gha,scope=${{ matrix.epics-target }} + cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }} + tags: ci_test + load: true + + - name: Test image + # can't test non native without some hardware to run on + if: ${{ matrix.epics-target == 'linux-x86_64' }} + run: tests/run-tests.sh ci_test + + - name: Push developer image + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} + uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{ matrix.platform }} + target: developer + build-args: | + IMAGE_EXT=${{ matrix.extension }} + tags: ${{ env.TAG }}-developer:${{ github.ref_name }} + push: true + + - name: Push runtime image + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} + uses: docker/build-push-action@v5 + with: + context: . + platforms: ${{ matrix.platform }} + target: runtime + build-args: | + IMAGE_EXT=${{ matrix.extension }} + tags: ${{ env.TAG }}-runtime:${{ github.ref_name }} + push: true + + release: + # Release on tag push - publish ioc schema + needs: [build] + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} + runs-on: ubuntu-latest + + # this job runs in the native developer container we just made + container: + image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-developer:${{ github.ref_name }} + + steps: + - name: generate-schema + run: | + ibek ioc generate-schema --output ibek.ioc.schema.json + + - name: Github Release + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15 + with: + files: | + ibek.ioc.schema.json + generate_release_notes: true diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index c793e00..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,47 +0,0 @@ -stages: - - container - -.build: - tags: - - argus - - docker-image - stage: container - variables: - GIT_SUBMODULE_STRATEGY: recursive - image: - name: gcr.io/diamond-privreg/container-tools/kaniko-executor:v1.9.1-debug - entrypoint: [""] - script: - - echo 'Building image...' - - env | grep "CI_" - - /bin/sh .gitlab/kanikobuild.sh - - echo "Done!" - # uncomment to only publish on tags. At present untagged builds are published - # to gcr.io/diamond-privreg/controls/work/ioc - # only: - # refs: - # - tags - -build_linux_runtime: - extends: .build - variables: - ARCH: linux - TARGET: runtime - -build_linux_developer: - extends: .build - variables: - ARCH: linux - TARGET: developer - -# build_rtems_runtime: -# extends: .build -# variables: -# ARCH: rtems -# TARGET: runtime - -# build_rtems_developer: -# extends: .build -# variables: -# ARCH: rtems -# TARGET: developer diff --git a/.gitlab/kanikobuild.sh b/.gitlab/kanikobuild.sh deleted file mode 100644 index 75a3284..0000000 --- a/.gitlab/kanikobuild.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# Script to be called by .gitlab-ci.yml to perform container build using gitlab kubernetes executor -# this script is designed for projects below the namespace /containers -# and deploys images to: -# $PROJECT_PATH in the work registry for untagged commits -# $PROJECT_PATH in the prod registry for tagged commits -# requires that CI_WORK_REGISTRY and CI_PROD_REGISTRY are set to a root path -# in your image registry for each of work and production images. -# See Settings->CI->Variables in the gitlab group /containers - -echo 'Building image...' -GROUP=${CI_PROJECT_NAMESPACE%%/containers*} -PROJECT_PATH=${CI_PROJECT_NAMESPACE##*containers/} - -if [ -z "${CI_COMMIT_TAG}" ]; then - DESTINATION=$CI_WORK_REGISTRY/$PROJECT_PATH/$CI_PROJECT_NAME - CI_COMMIT_TAG=$CI_COMMIT_REF_NAME -else - DESTINATION=$CI_PROD_REGISTRY/$PROJECT_PATH/$CI_PROJECT_NAME -fi - -CMDROOT="/kaniko/executor --context $CI_PROJECT_DIR --build-arg EPICS_TARGET_ARCH=${ARCH}" -CMD=$CMDROOT" --target ${TARGET}" -CMD=$CMD" --destination $DESTINATION-${ARCH}-${TARGET}:$CI_COMMIT_TAG" - -( - set -x - $CMD -) diff --git a/README.md b/README.md index 95fa33c..30b274c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Generic IOC Template Repository ioc-andor3 +# Generic IOC Template Repository ioc-adandor3 ## Description A Generic IOC for andor3 cameras @@ -13,7 +13,7 @@ To update to the latest version of the template: # activate a python virtual environment pip install copier -cd ioc-andor3 +cd ioc-adandor3 copier update -a --trust . ```