From d7c5c80d70bd267ec9bf8087befb86df931384b4 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Mon, 12 Aug 2024 20:03:20 +0000 Subject: [PATCH 1/8] Update github action to use docker action as well as build for arm64 --- .github/workflows/build.yaml | 39 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1befdfc..0d4ca7b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,26 +15,23 @@ jobs: packages: write contents: read steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - name: Build swarm image - run: | - docker build . \ - --build-arg JSWARM_UID=48435 \ - --build-arg JSWARM_GID=202 \ - --tag $CONTAINER_NAME \ - --label "runnumber=${GITHUB_RUN_ID}" - - name: Log in to GitHub Container Registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Push images - run: | - CONTAINER_ID=ghcr.io/${{ github.repository_owner }}/$CONTAINER_NAME - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - [ "$VERSION" == "master" ] && VERSION=latest - echo CONTAINER_ID=$CONTAINER_ID - echo VERSION=$VERSION - docker tag $CONTAINER_NAME $CONTAINER_ID:$VERSION - docker push $CONTAINER_ID:$VERSION + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/${{ github.repository }}:${{ [github.ref_name = "master"] && echo "latest" ||echo "merge" }} + build-args: JSWARM_UID=48435,JSWARM_GID=202 + labels: runnumber=${{ GITHUB_RUN_ID }} From 95d061dcd24a57420379fb4739549f2465a7f932 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Mon, 12 Aug 2024 20:05:45 +0000 Subject: [PATCH 2/8] Add docker meta to automate tags --- .github/workflows/build.yaml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0d4ca7b..80e7f19 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,6 +17,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable=${{ github.ref_name == 'master' }} + type=raw,value=merge,enable=${{ github.ref_name != 'master' }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -32,6 +40,8 @@ jobs: with: platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/${{ github.repository }}:${{ [github.ref_name = "master"] && echo "latest" ||echo "merge" }} - build-args: JSWARM_UID=48435,JSWARM_GID=202 - labels: runnumber=${{ GITHUB_RUN_ID }} + tags: ${{ steps.meta.outputs.tags }} + build-args: | + JSWARM_UID=48435 + JSWARM_GID=202 + labels: runnumber=${{ github.run_id }} From 78daa52891cdd2dfd0c8e8498665d2461539bb81 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Mon, 12 Aug 2024 20:57:15 +0000 Subject: [PATCH 3/8] Fix Docker lint issue. FromAsCasing: 'as' and 'FROM' keywords' --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ff119f..63d1b35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # # download swarm jar # -FROM alpine:3 as downloader +FROM alpine:3 AS downloader ARG JSWARM_VERSION=3.46 ARG JSWARM_JAR_NAME=swarm-client-${JSWARM_VERSION}.jar @@ -19,7 +19,7 @@ RUN curl -sSLo /${JMXEX_JAR_NAME} ${JMXEX_URL} # # pkg base # -FROM alpine:3 as pkg_base +FROM alpine:3 AS pkg_base RUN apk add --no-cache --upgrade openjdk21 bash git docker make From 77deeb8779929bd3678d8e98571174c114939d1d Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Tue, 13 Aug 2024 01:39:35 +0000 Subject: [PATCH 4/8] Add ymllint, shellcheck and other actions --- .github/workflows/build.yaml | 2 +- .github/workflows/markdownlint.yaml | 17 +++++++++++++++++ .github/workflows/rebase_checker.yaml | 8 ++++++++ .github/workflows/shellcheck.yaml | 18 ++++++++++++++++++ .github/workflows/yamllint.yaml | 25 +++++++++++++++++++++++++ .yamllint | 5 +++++ 6 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/markdownlint.yaml create mode 100644 .github/workflows/rebase_checker.yaml create mode 100644 .github/workflows/shellcheck.yaml create mode 100644 .github/workflows/yamllint.yaml create mode 100644 .yamllint diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 80e7f19..f65f60d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ jobs: contents: read steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker meta id: meta uses: docker/metadata-action@v5 diff --git a/.github/workflows/markdownlint.yaml b/.github/workflows/markdownlint.yaml new file mode 100644 index 0000000..a701171 --- /dev/null +++ b/.github/workflows/markdownlint.yaml @@ -0,0 +1,17 @@ +--- +name: Lint Markdown Files + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Run linter + uses: actionshub/markdownlint@main diff --git a/.github/workflows/rebase_checker.yaml b/.github/workflows/rebase_checker.yaml new file mode 100644 index 0000000..62aeca7 --- /dev/null +++ b/.github/workflows/rebase_checker.yaml @@ -0,0 +1,8 @@ +--- +name: Check that 'main' is not merged into the development branch + +on: pull_request + +jobs: + call-workflow: + uses: lsst/rubin_workflows/.github/workflows/rebase_checker.yaml@main diff --git a/.github/workflows/shellcheck.yaml b/.github/workflows/shellcheck.yaml new file mode 100644 index 0000000..eb011bd --- /dev/null +++ b/.github/workflows/shellcheck.yaml @@ -0,0 +1,18 @@ +--- +name: shellcheck + +on: + push: + branches: + - main + pull_request: + +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Run shellcheck + uses: ludeeus/action-shellcheck@master + # See https://github.com/ludeeus/action-shellcheck for customizations diff --git a/.github/workflows/yamllint.yaml b/.github/workflows/yamllint.yaml new file mode 100644 index 0000000..cb17767 --- /dev/null +++ b/.github/workflows/yamllint.yaml @@ -0,0 +1,25 @@ +--- +name: Lint YAML Files + +on: + push: + branches: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.12 + + - name: Install + run: pip install yamllint + + - name: Run linter + run: yamllint . diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..7214609 --- /dev/null +++ b/.yamllint @@ -0,0 +1,5 @@ +--- +extends: default +rules: + truthy: + check-keys: false From 17b251c7cdbd2e0016acbf58eb50ffbfe6767767 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Tue, 13 Aug 2024 01:42:03 +0000 Subject: [PATCH 5/8] Remove old travis files --- .hadolint.yaml | 8 -------- .travis.yml | 32 -------------------------------- Makefile | 11 ----------- tests/hadolint.sh | 28 ---------------------------- tests/make.sh | 31 ------------------------------- tests/mdl.sh | 26 -------------------------- tests/shellcheck.sh | 26 -------------------------- tests/yamllint.sh | 38 -------------------------------------- 8 files changed, 200 deletions(-) delete mode 100644 .hadolint.yaml delete mode 100644 .travis.yml delete mode 100644 Makefile delete mode 100755 tests/hadolint.sh delete mode 100755 tests/make.sh delete mode 100755 tests/mdl.sh delete mode 100755 tests/shellcheck.sh delete mode 100755 tests/yamllint.sh diff --git a/.hadolint.yaml b/.hadolint.yaml deleted file mode 100644 index 179e48f..0000000 --- a/.hadolint.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -ignored: - # disable USER root - - DL3002 - # disable pinning apk package versions - - DL3018 - # disable following sourced files - - SC1091 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 338cce8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -sudo: false -language: c -matrix: - include: - - &docker - env: TEST=markdownlint - services: - - docker - script: ./tests/mdl.sh - - - <<: *docker - env: TEST=yamllint - script: ./tests/yamllint.sh - - - <<: *docker - env: TEST=shellcheck - script: ./tests/shellcheck.sh - - - <<: *docker - env: TEST=hadolint - script: ./tests/hadolint.sh - - - env: TEST=make - script: ./tests/make.sh -branches: - only: - - master - # also matched against tag pushes - - /^\d+\.\d+\.\d+$/ -notifications: - email: false diff --git a/Makefile b/Makefile deleted file mode 100644 index bd9a690..0000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -all: build - -build: - docker build \ - -t lsstsqre/jenkins-swarm-client . - -ldfc: - docker build \ - --build-arg JSWARM_UID=48435 \ - --build-arg JSWARM_GID=202 \ - -t lsstsqre/jenkins-swarm-client:ldfc . diff --git a/tests/hadolint.sh b/tests/hadolint.sh deleted file mode 100755 index fb8b19a..0000000 --- a/tests/hadolint.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -e -shopt -s globstar nullglob - -CHECK=( **/Dockerfile ) -IGNORE=() - -for c in "${!CHECK[@]}"; do - for i in "${IGNORE[@]}"; do - [[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]' - done -done -[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; } - -echo '---' -echo 'check:' -for c in "${CHECK[@]}"; do - echo " - ${c}" -done -echo - -for f in "${CHECK[@]}"; do - docker run -ti -v "$(pwd):$(pwd)" -w "$(pwd)" \ - hadolint/hadolint:v1.13.0 hadolint "$f" -done - -# vim: tabstop=2 shiftwidth=2 expandtab diff --git a/tests/make.sh b/tests/make.sh deleted file mode 100755 index 341d206..0000000 --- a/tests/make.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -e -shopt -s globstar nullglob - -CHECK=( **/Makefile ) -IGNORE=() - -for c in "${!CHECK[@]}"; do - for i in "${IGNORE[@]}"; do - [[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]' - done -done -[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; } - -echo '---' -echo 'check:' -for c in "${CHECK[@]}"; do - echo " - ${c}" -done -echo - -for f in "${CHECK[@]}"; do - ( set -e - cd "$(dirname "$f")" - echo "checking $f" - make --dry-run --warn-undefined-variables - ) -done - -# vim: tabstop=2 shiftwidth=2 expandtab diff --git a/tests/mdl.sh b/tests/mdl.sh deleted file mode 100755 index 40fa8e6..0000000 --- a/tests/mdl.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -e -shopt -s globstar nullglob - -CHECK=( **/*.md ) -IGNORE=() - -for c in "${!CHECK[@]}"; do - for i in "${IGNORE[@]}"; do - [[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]' - done -done -[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; } - -echo '---' -echo 'check:' -for c in "${CHECK[@]}"; do - echo " - ${c}" -done -echo - -docker run -ti -v "$(pwd):$(pwd)" -w "$(pwd)" \ - mivok/markdownlint:0.4.0 "${CHECK[@]}" - -# vim: tabstop=2 shiftwidth=2 expandtab diff --git a/tests/shellcheck.sh b/tests/shellcheck.sh deleted file mode 100755 index f067e9f..0000000 --- a/tests/shellcheck.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -e -shopt -s globstar nullglob - -CHECK=( **/*.sh ) -IGNORE=( {environments,.bundle,.tmp}/** ) - -for c in "${!CHECK[@]}"; do - for i in "${IGNORE[@]}"; do - [[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]' - done -done -[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; } - -echo '---' -echo 'check:' -for c in "${CHECK[@]}"; do - echo " - ${c}" -done -echo - -docker run -ti -v "$(pwd):$(pwd)" -w "$(pwd)" \ - koalaman/shellcheck-alpine:v0.6.0 shellcheck -x "${CHECK[@]}" - -# vim: tabstop=2 shiftwidth=2 expandtab diff --git a/tests/yamllint.sh b/tests/yamllint.sh deleted file mode 100755 index dfa18ba..0000000 --- a/tests/yamllint.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -set -e -shopt -s globstar nullglob - -CHECK=( **/*.{yaml,yml,.eyaml} .*.{yml,yaml} ) -EYAML=( **/*.eyaml ) -IGNORE=() -CONF_FILE=".yamllint.yaml" - -# filter out plain text versions of .eyaml files -for e in "${!EYAML[@]}"; do - uneyaml=${EYAML[e]/eyaml/yaml} - for c in "${!CHECK[@]}"; do - [[ ${CHECK[c]} == "$uneyaml" ]] && unset -v 'CHECK[c]' - done -done - -for c in "${!CHECK[@]}"; do - for i in "${IGNORE[@]}"; do - [[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]' - done -done -[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; } - -echo '---' -echo 'check:' -for c in "${CHECK[@]}"; do - echo " - ${c}" -done -echo - -ARGS=() -[[ -f $CONF_FILE ]] && ARGS+=(-c "$CONF_FILE") -ARGS+=("${CHECK[@]}") -docker run -ti -v "$(pwd):/workdir" lsstsqre/yamllint:1.13.0 "${ARGS[@]}" - -# vim: tabstop=2 shiftwidth=2 expandtab From e60dc1d15973b463208915bc0ba83970fdc6c987 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Tue, 13 Aug 2024 01:45:45 +0000 Subject: [PATCH 6/8] Update Readme to new registry --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba19f3c..12e59f7 100644 --- a/README.md +++ b/README.md @@ -10,5 +10,5 @@ Usage --- ```sh -docker run -ti lsstsqre/jenkins-swarm-client +docker run -ti ghcr.io/lsst-dm/jenkins-swarm-client ``` From d98e82da2fc6a2359e1c7d5094c79901417e11b6 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Tue, 13 Aug 2024 01:48:00 +0000 Subject: [PATCH 7/8] Fix yaml linting --- .github/workflows/build.yaml | 5 ++++- .github/workflows/markdownlint.yaml | 9 ++------- .github/workflows/shellcheck.yaml | 18 ------------------ .github/workflows/yamllint.yaml | 20 ++------------------ 4 files changed, 8 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/shellcheck.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f65f60d..f1ef40f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,3 +1,4 @@ +--- name: Build Jenkins swarm client container on: push: @@ -24,7 +25,9 @@ jobs: images: ghcr.io/${{ github.repository }} tags: | type=raw,value=latest,enable=${{ github.ref_name == 'master' }} - type=raw,value=merge,enable=${{ github.ref_name != 'master' }} + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr,suffix=/${{ github.head_ref }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.github/workflows/markdownlint.yaml b/.github/workflows/markdownlint.yaml index a701171..e6685c0 100644 --- a/.github/workflows/markdownlint.yaml +++ b/.github/workflows/markdownlint.yaml @@ -8,10 +8,5 @@ on: pull_request: jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v4 - - name: Run linter - uses: actionshub/markdownlint@main + call-workflow: + uses: lsst/rubin_workflows/.github/workflows/markdownlint.yaml@main diff --git a/.github/workflows/shellcheck.yaml b/.github/workflows/shellcheck.yaml deleted file mode 100644 index eb011bd..0000000 --- a/.github/workflows/shellcheck.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: shellcheck - -on: - push: - branches: - - main - pull_request: - -jobs: - shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Run shellcheck - uses: ludeeus/action-shellcheck@master - # See https://github.com/ludeeus/action-shellcheck for customizations diff --git a/.github/workflows/yamllint.yaml b/.github/workflows/yamllint.yaml index cb17767..757dbd8 100644 --- a/.github/workflows/yamllint.yaml +++ b/.github/workflows/yamllint.yaml @@ -2,24 +2,8 @@ name: Lint YAML Files on: - push: - branches: - - main pull_request: jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: 3.12 - - - name: Install - run: pip install yamllint - - - name: Run linter - run: yamllint . + call-workflow: + uses: lsst/rubin_workflows/.github/workflows/yamllint.yaml@main From 401220275eb133a2151d80e6efeea7196fc0a113 Mon Sep 17 00:00:00 2001 From: Ross Ceballo Date: Tue, 13 Aug 2024 20:47:38 -0400 Subject: [PATCH 8/8] Move docker action to lsst-dm/build-and-push --- .github/workflows/build.yaml | 27 +++------------------------ .github/workflows/markdownlint.yaml | 1 - .github/workflows/rebase_checker.yaml | 1 - .github/workflows/yamllint.yaml | 1 - .yamllint | 1 - 5 files changed, 3 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f1ef40f..afe2fe8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,9 +1,8 @@ ---- name: Build Jenkins swarm client container on: push: branches: - - master + - main pull_request: env: @@ -18,32 +17,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=latest,enable=${{ github.ref_name == 'master' }} - type=ref,event=branch - type=ref,event=tag - type=ref,event=pr,suffix=/${{ github.head_ref }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v6 + uses: lsst-dm/build-and-push@main with: platforms: linux/amd64,linux/arm64 + github_token: ${{ secrets.GITHUB_TOKEN }} push: true - tags: ${{ steps.meta.outputs.tags }} build-args: | JSWARM_UID=48435 JSWARM_GID=202 diff --git a/.github/workflows/markdownlint.yaml b/.github/workflows/markdownlint.yaml index e6685c0..04dc554 100644 --- a/.github/workflows/markdownlint.yaml +++ b/.github/workflows/markdownlint.yaml @@ -1,4 +1,3 @@ ---- name: Lint Markdown Files on: diff --git a/.github/workflows/rebase_checker.yaml b/.github/workflows/rebase_checker.yaml index 62aeca7..65516d9 100644 --- a/.github/workflows/rebase_checker.yaml +++ b/.github/workflows/rebase_checker.yaml @@ -1,4 +1,3 @@ ---- name: Check that 'main' is not merged into the development branch on: pull_request diff --git a/.github/workflows/yamllint.yaml b/.github/workflows/yamllint.yaml index 757dbd8..5962342 100644 --- a/.github/workflows/yamllint.yaml +++ b/.github/workflows/yamllint.yaml @@ -1,4 +1,3 @@ ---- name: Lint YAML Files on: diff --git a/.yamllint b/.yamllint index 7214609..9fad077 100644 --- a/.yamllint +++ b/.yamllint @@ -1,4 +1,3 @@ ---- extends: default rules: truthy: