From 0f779e657722e6b78f08809f45378bd9d8dfe791 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 23 Sep 2020 11:36:12 +0200 Subject: [PATCH] Switch to github workflow Add the github/ghcr equivalent to travis/dockerhub. With this in place, we can also deploy the next and latest images to ghcr. Adjust Dockerfile.isar accordingly. Also update the badge shown in the README. We model the workflow with github a bit differently than so far: next and master branch are different workflows. The former includes testing, the latter just updates the container image. This is based on the (offline) workflow to push changes to next first and have no commits in master that haven't been in next before, except for release commits. The master workflow also triggers on tags in which case it additionally tags the container images accordingly and pushed that as well. Travis is removed in the same run to avoid pushing differently built images to the different registries. Signed-off-by: Jan Kiszka --- .github/workflows/master.yml | 38 ++++++++++++++++++ .github/workflows/next.yml | 73 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 45 +++++++++++++++++++++ .travis.yml | 52 ------------------------- Dockerfile.isar | 2 +- README.rst | 22 +++++------ 6 files changed, 168 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/master.yml create mode 100644 .github/workflows/next.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000..3405cc1 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,38 @@ +name: master + +on: + push: + branches: + - master + +jobs: + deploy_containers: + name: Build and deploy container images + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.PACKAGE_DEPLOY_USER }} + password: ${{ secrets.PACKAGE_DEPLOY_TOKEN }} + - name: Build kas image + uses: docker/build-push-action@v2 + with: + tags: ghcr.io/siemens/kas/kas + - name: Build kas-isar image + uses: docker/build-push-action@v2 + with: + file: Dockerfile.isar + tags: ghcr.io/siemens/kas/kas-isar + - name: Push images + run: | + # The release workflow will push :latest for tagged revisions + if ! git describe --exact-match --tags --match '*.*'; then + docker push ghcr.io/siemens/kas/kas + docker push ghcr.io/siemens/kas/kas-isar + fi diff --git a/.github/workflows/next.yml b/.github/workflows/next.yml new file mode 100644 index 0000000..3cdd760 --- /dev/null +++ b/.github/workflows/next.yml @@ -0,0 +1,73 @@ +name: next + +on: + push: + branches: + - next + +env: + SHELLCHECK_VERSION: v0.7.1 + +jobs: + perform_tests: + name: Run tests on kas code + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.5, 3.6, 3.7, 3.8] + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - name: Install Python dependencies of kas and tests + run: | + # install kas to have all kas dependencies: + pip install . + # checkcode dependencies: + pip install flake8 pycodestyle doc8 Pygments + # test dependencies: + pip install -U pytest + - name: Install recent shellcheck + run: | + wget -q https://github.com/koalaman/shellcheck/releases/download/$SHELLCHECK_VERSION/shellcheck-$SHELLCHECK_VERSION.linux.x86_64.tar.xz + tar -xJf shellcheck-$SHELLCHECK_VERSION.linux.x86_64.tar.xz + sudo cp shellcheck-$SHELLCHECK_VERSION/shellcheck /usr/local/bin/ + - name: Run tests + run: | + scripts/checkcode.sh . + pytest + + deploy_containers: + name: Build and deploy container images + needs: perform_tests + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.PACKAGE_DEPLOY_USER }} + password: ${{ secrets.PACKAGE_DEPLOY_TOKEN }} + - name: Build kas image + uses: docker/build-push-action@v2 + with: + tags: | + ghcr.io/siemens/kas/kas + ghcr.io/siemens/kas/kas:next + - name: Build kas-isar image + uses: docker/build-push-action@v2 + with: + file: Dockerfile.isar + tags: | + ghcr.io/siemens/kas/kas-isar + ghcr.io/siemens/kas/kas-isar:next + - name: Push images + run: | + docker push ghcr.io/siemens/kas/kas:next + docker push ghcr.io/siemens/kas/kas-isar:next diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c6212fc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: release + +on: + push: + tags: + - '*.*' + +jobs: + deploy_containers: + name: Build and deploy container images + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Get release + run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/tags/} + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.PACKAGE_DEPLOY_USER }} + password: ${{ secrets.PACKAGE_DEPLOY_TOKEN }} + - name: Build kas image + uses: docker/build-push-action@v2 + with: + tags: | + ghcr.io/siemens/kas/kas + ghcr.io/siemens/kas/kas:${{ env.RELEASE_VERSION }} + ghcr.io/siemens/kas/kas:latest-release + - name: Build kas-isar image + uses: docker/build-push-action@v2 + with: + file: Dockerfile.isar + tags: | + ghcr.io/siemens/kas/kas-isar + ghcr.io/siemens/kas/kas-isar:${{ env.RELEASE_VERSION }} + ghcr.io/siemens/kas/kas-isar:latest-release + - name: Push images + run: | + docker push ghcr.io/siemens/kas/kas + docker push ghcr.io/siemens/kas/kas:${{ env.RELEASE_VERSION }} + docker push ghcr.io/siemens/kas/kas:latest-release + docker push ghcr.io/siemens/kas/kas-isar + docker push ghcr.io/siemens/kas/kas-isar:${{ env.RELEASE_VERSION }} + docker push ghcr.io/siemens/kas/kas-isar:latest-release diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0bc1292..0000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: python -dist: xenial - -python: - - "3.5" - - "3.6" - - "3.7" - - "3.8" - -services: - - docker - -install: - # install kas to have all kas dependencies: - - pip install . - # checkcode dependencies: - - pip install flake8 pycodestyle doc8 Pygments - # test dependencies: - - pip install -U pytest - # workaround, needed because kas uses a cleaned-up PATH internally - - sudo ln -s /usr/local/bin/hg /usr/bin/ - -script: - - scripts/checkcode.sh . - - pytest - -jobs: - include: - - stage: docker - python: "3.6" - script: - - docker build -t kasproject/kas . - - docker build -t kasproject/kas-isar -f Dockerfile.isar . - - TAG=`git describe --exact-match --tags 2>/dev/null || echo ""` - - case "$TRAVIS_BRANCH" in - master|next|"$TAG") - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"; - for IMAGE in kasproject/kas kasproject/kas-isar; do - if [ "$TRAVIS_BRANCH" == "$TAG" ]; then - docker tag $IMAGE $IMAGE:$TAG; - docker push $IMAGE:$TAG; - docker tag $IMAGE $IMAGE:latest-release; - docker push $IMAGE:latest-release; - elif [ "$TRAVIS_BRANCH" == "next" ]; then - docker tag $IMAGE $IMAGE:next; - docker push $IMAGE:next; - else - docker push $IMAGE; - fi - done - ;; - esac diff --git a/Dockerfile.isar b/Dockerfile.isar index cde63b0..cbf24b7 100644 --- a/Dockerfile.isar +++ b/Dockerfile.isar @@ -1,6 +1,6 @@ # This image builds Isar jobs using the kas tool -FROM kasproject/kas:latest +FROM ghcr.io/siemens/kas/kas:latest ENV LC_ALL=en_US.UTF-8 RUN echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/buster-backports.list && \ diff --git a/README.rst b/README.rst index 24b1b13..5d2547d 100644 --- a/README.rst +++ b/README.rst @@ -1,18 +1,18 @@ Setup tool for bitbake based projects ===================================== -+------------+------------------+ -| Branch | Build Status | -+============+==================+ -| ``master`` | |travis-master|_ | -+------------+------------------+ -| ``next`` | |travis-next|_ | -+------------+------------------+ ++--------------------+ +| Build Status | ++====================+ +| |workflow-master|_ | ++--------------------+ +| |workflow-next|_ | ++--------------------+ -.. |travis-master| image:: https://travis-ci.org/siemens/kas.svg?branch=master -.. _travis-master: https://travis-ci.org/siemens/kas/branches -.. |travis-next| image:: https://travis-ci.org/siemens/kas.svg?branch=next -.. _travis-next: https://travis-ci.org/siemens/kas/branches +.. |workflow-master| image:: https://github.com/siemens/kas/workflows/master/badge.svg +.. _workflow-master: https://github.com/siemens/kas/actions?query=workflow%3Amaster +.. |workflow-next| image:: https://github.com/siemens/kas/workflows/next/badge.svg +.. _workflow-next: https://github.com/siemens/kas/actions?query=workflow%3Anext This tool provides an easy mechanism to setup bitbake based projects.