From 6775028e9bd29593b89152c9c543a9fdfac1ee6b Mon Sep 17 00:00:00 2001 From: TP Honey Date: Thu, 22 Dec 2022 09:24:52 +0000 Subject: [PATCH] (maint) move to harness.drone.io --- .drone.star | 105 ---- .drone.yml | 475 ++++++++++-------- docker/Dockerfile.linux.arm | 22 - docker/Dockerfile.windows.amd64.1909 | 12 - ...1903 => Dockerfile.windows.amd64.ltsc2022} | 8 +- docker/manifest.tmpl | 28 +- scripts/windows/latest.ps1 | 25 - scripts/windows/tag.ps1 | 51 -- 8 files changed, 268 insertions(+), 458 deletions(-) delete mode 100644 .drone.star delete mode 100644 docker/Dockerfile.linux.arm delete mode 100644 docker/Dockerfile.windows.amd64.1909 rename docker/{Dockerfile.windows.amd64.1903 => Dockerfile.windows.amd64.ltsc2022} (55%) delete mode 100644 scripts/windows/latest.ps1 delete mode 100644 scripts/windows/tag.ps1 diff --git a/.drone.star b/.drone.star deleted file mode 100644 index c218d83..0000000 --- a/.drone.star +++ /dev/null @@ -1,105 +0,0 @@ -# go version -go = "golang:1.13" - -# docker repository -repo = "drone/drone-runner-docker" - -def main(ctx): - return [ - pipeline_linux(), - pipeline_windows("1903"), - pipeline_windows("1809"), - pipeline_manifest(), - # manifest - ] - - -def pipeline_linux(): - return { - "kind": "pipeline", - "type": "docker", - "name": "linux", - "steps": [ - test, - build, - publish("arm"), - publish("arm64"), - publish("amd64"), - ] - } - -def pipeline_windows(version): - return { - "kind": "pipeline", - "type": "ssh", - "name": "windows_%s" % version, - "server": { - - }, - "platform": { - "os": "windows", - }, - "steps": [ - "sh scripts/ci_%s.ps1" % version, - ], - } - -def pipeline_manifest(): - return [ - "kind": "pipeline", - "type": "docker", - "name": "linux", - "steps": [ - { - - } - ] - ] - -# publish creates a docker publish step. -def publish(arch): - return { - "name": "publish_%s" % arch, - "image": "plugins/docker", - "pull": "if-not-exists", - "settings": { - "auto_tag": "true", - "auto_tag_suffix": "linux-%s" % arch, - "dockerfile": "docker/Dockerfile.linux.%s" % arch, - "repo": repo, - }, - "when": { - "event": [ "push", "tag" ] - } - } - -# test defines a test step that downloads -# dependencies and tests the packages. -test = { - "name": "test", - "image": go, - "volumes": mounts, - "commands": [ - "go test -v ./...", - ], -} - -# build defines a build step that compiles -# the binaries. -build = { - "name": "build", - "image": go, - "volumes": mounts, - "commands": [ - "sh scripts/build.sh", - ], - "when": { - "event": [ "push", "tag" ] - } -} - -# mount points shared by all steps. -mounts = [{ - "name": "go", - "path": "/go", -}] diff --git a/.drone.yml b/.drone.yml index dea6fbe..30fb00c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,278 +1,327 @@ kind: pipeline -type: docker -name: linux +type: vm +name: testing + +pool: + use: ubuntu platform: os: linux arch: amd64 steps: -- name: test - image: golang:1.16 - commands: - - go test -cover ./... - volumes: - - name: go - path: /go + - name: test + image: golang:1.16 + commands: + - go test -cover ./... + volumes: + - name: go + path: /go + + - name: build + image: golang:1.16 + commands: + - sh scripts/build.sh + volumes: + - name: go + path: /go -- name: build - image: golang:1.16 - commands: - - sh scripts/build.sh - volumes: +volumes: - name: go - path: /go - when: - event: - - push - - tag - -- name: publish_amd64 - image: plugins/docker - pull: if-not-exists - settings: - repo: drone/drone-runner-docker - auto_tag: true - auto_tag_suffix: linux-amd64 - dockerfile: docker/Dockerfile.linux.amd64 - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - ref: - - refs/heads/master - - refs/tags/* + temp: {} -- name: publish_arm - image: plugins/docker - pull: if-not-exists - settings: - repo: drone/drone-runner-docker - auto_tag: true - auto_tag_suffix: linux-arm - platform: linux/arm/v7 - dockerfile: docker/Dockerfile.linux.arm - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - ref: - - refs/heads/master - - refs/tags/* +--- -- name: publish_arm64 - image: plugins/docker - pull: if-not-exists - settings: - repo: drone/drone-runner-docker - auto_tag: true - auto_tag_suffix: linux-arm64 - platform: linux/arm64 - dockerfile: docker/Dockerfile.linux.arm64 - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - ref: - - refs/heads/master - - refs/tags/* +kind: pipeline +type: vm +name: linux-amd64 +platform: + os: linux + arch: amd64 +pool: + use: ubuntu -- name: publish_ppc64le - image: plugins/docker - pull: if-not-exists - settings: - repo: drone/drone-runner-docker - auto_tag: true - auto_tag_suffix: linux-ppc64le - platform: linux/ppc64le - dockerfile: docker/Dockerfile.linux.ppc64le - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - ref: - - refs/heads/master - - refs/tags/* +steps: + - name: environment + image: golang:1.16 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.16 + environment: + CGO_ENABLED: "0" + commands: + - go build -o release/linux/amd64/drone-runner-docker + - name: publish + image: plugins/docker + pull: if-not-exists + settings: + repo: drone/drone-runner-docker + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: docker/Dockerfile.linux.amd64 + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + ref: + - refs/heads/master + - refs/tags/* -volumes: -- name: go - temp: {} +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** --- -kind: pipeline -type: ssh -name: windows-1903 + +kind: pipeline +type: vm +name: linux-arm64 platform: - os: windows + os: linux + arch: arm64 +pool: + use: ubuntu_arm64 + +steps: + - name: environment + image: golang:1.16 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.16 + environment: + CGO_ENABLED: "0" + commands: + - go build -o release/linux/arm64/drone-runner-docker + - name: publish + image: plugins/docker + pull: if-not-exists + settings: + repo: drone/drone-runner-docker + auto_tag: true + auto_tag_suffix: linux-arm64 + dockerfile: docker/Dockerfile.linux.arm64 + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + ref: + - refs/heads/master + - refs/tags/* -server: - host: - from_secret: windows_server_1903 - password: - from_secret: windows_password - user: - from_secret: windows_username +depends_on: + - testing + +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +--- + +kind: pipeline +type: vm +name: linux-ppc64le +platform: + os: linux + arch: amd64 +pool: + use: ubuntu steps: -- name: build_latest - environment: - VERSION: 1903 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/latest.ps1 - when: - event: [ push ] - -- name: build_tag - environment: - VERSION: 1903 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/tag.ps1 - when: - event: [ tag ] + - name: environment + image: golang:1.16 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.16 + environment: + CGO_ENABLED: "0" + commands: + - go build -o release/linux/ppc64le/drone-runner-docker + - name: publish + image: plugins/docker + pull: if-not-exists + settings: + repo: drone/drone-runner-docker + auto_tag: true + auto_tag_suffix: linux-ppc64le + platform: linux/ppc64le + dockerfile: docker/Dockerfile.linux.ppc64le + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + ref: + - refs/heads/master + - refs/tags/* depends_on: -- linux + - testing trigger: ref: - - refs/heads/master - - refs/tags/* + - refs/heads/master + - refs/tags/** + - refs/pull/** --- kind: pipeline -type: ssh +type: vm name: windows-1809 platform: os: windows + arch: amd64 -server: - host: - from_secret: windows_server_1809 - password: - from_secret: windows_password - user: - from_secret: windows_username +pool: + use: windows steps: -- name: build_latest - environment: - VERSION: 1809 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/latest.ps1 - when: - event: [ push ] - -- name: build_tag - environment: - VERSION: 1809 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/tag.ps1 - when: - event: [ tag ] + - name: environment + image: golang:1.16 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.16 + environment: + CGO_ENABLED: "0" + commands: + - go build -o release/windows/amd64/drone-runner-docker.exe + - name: docker + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.windows.1809 + repo: drone/drone-runner-docker + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + auto_tag_suffix: windows-1809-amd64 + daemon_off: true + purge: false + when: + ref: + - refs/heads/master + - refs/tags/** depends_on: -- linux + - testing trigger: ref: - - refs/heads/master - - refs/tags/* + - refs/heads/master + - refs/tags/** + - refs/pull/** --- kind: pipeline -type: ssh -name: windows-1909 +type: vm +name: windows-ltsc2022 platform: os: windows + arch: amd64 -server: - host: - from_secret: windows_server_1909 - password: - from_secret: windows_password - user: - from_secret: windows_username +pool: + use: windows-2022 steps: -- name: build_latest - environment: - VERSION: 1909 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/latest.ps1 - when: - event: [ push ] - -- name: build_tag - environment: - VERSION: 1909 - USERNAME: - from_secret: docker_username - PASSWORD: - from_secret: docker_password - commands: - - powershell.exe scripts/windows/tag.ps1 - when: - event: [ tag ] + - name: environment + image: golang:1.16 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.16 + environment: + CGO_ENABLED: "0" + commands: + - go build -o release/windows/amd64/drone-runner-docker.exe + - name: docker + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.windows.ltsc2022 + repo: drone/drone-runner-docker + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + auto_tag_suffix: windows-ltsc2022-amd64 + daemon_off: true + purge: false + when: + ref: + - refs/heads/master + - refs/tags/** depends_on: -- linux - + - testing + trigger: ref: - - refs/heads/master - - refs/tags/* + - refs/heads/master + - refs/tags/** + - refs/pull/** --- + kind: pipeline type: docker name: manifest steps: -- name: manifest - image: plugins/manifest - settings: - spec: docker/manifest.tmpl - auto_tag: true - ignore_missing: true - password: - from_secret: docker_password - username: - from_secret: docker_username + - name: manifest + image: plugins/manifest + settings: + spec: docker/manifest.tmpl + auto_tag: true + ignore_missing: true + password: + from_secret: docker_password + username: + from_secret: docker_username depends_on: -- windows-1903 -- windows-1809 -- windows-1909 + - linux-amd64 + - linux-arm64 + - linux-ppc64le + - windows-1809 + - windows-ltsc2022 trigger: ref: - - refs/heads/master - - refs/tags/* - + - refs/heads/master + - refs/tags/* diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm deleted file mode 100644 index 3f4d586..0000000 --- a/docker/Dockerfile.linux.arm +++ /dev/null @@ -1,22 +0,0 @@ -FROM alpine:3 as alpine -RUN apk add -U --no-cache ca-certificates - -RUN wget https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-arm32v7.tar.xz -RUN tar -xf tmate-2.4.0-static-linux-arm32v7.tar.xz -RUN mv tmate-2.4.0-static-linux-arm32v7/tmate /bin/ -RUN chmod +x /bin/tmate - -FROM scratch -EXPOSE 3000 - -ENV GODEBUG netdns=go -ENV DRONE_PLATFORM_OS linux -ENV DRONE_PLATFORM_ARCH arm - -COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=alpine /bin/tmate /bin/ - -LABEL com.centurylinklabs.watchtower.stop-signal="SIGINT" - -ADD release/linux/arm/drone-runner-docker /bin/ -ENTRYPOINT ["/bin/drone-runner-docker"] diff --git a/docker/Dockerfile.windows.amd64.1909 b/docker/Dockerfile.windows.amd64.1909 deleted file mode 100644 index 2166b0d..0000000 --- a/docker/Dockerfile.windows.amd64.1909 +++ /dev/null @@ -1,12 +0,0 @@ -# escape=` -FROM mcr.microsoft.com/windows/nanoserver:1909 -USER ContainerAdministrator - -EXPOSE 3000 -ENV GODEBUG netdns=go -ENV DRONE_PLATFORM_OS windows -ENV DRONE_PLATFORM_ARCH amd64 -ENV DRONE_PLATFORM_KERNEL 1909 - -ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe -ENTRYPOINT [ "C:\\drone-runner-docker.exe" ] \ No newline at end of file diff --git a/docker/Dockerfile.windows.amd64.1903 b/docker/Dockerfile.windows.amd64.ltsc2022 similarity index 55% rename from docker/Dockerfile.windows.amd64.1903 rename to docker/Dockerfile.windows.amd64.ltsc2022 index 552c6c8..b3a1e2a 100644 --- a/docker/Dockerfile.windows.amd64.1903 +++ b/docker/Dockerfile.windows.amd64.ltsc2022 @@ -1,12 +1,12 @@ # escape=` -FROM mcr.microsoft.com/windows/nanoserver:1903 +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 USER ContainerAdministrator EXPOSE 3000 -ENV GODEBUG netdns=go +ENV GODEBUG=netdns=go ENV DRONE_PLATFORM_OS windows ENV DRONE_PLATFORM_ARCH amd64 -ENV DRONE_PLATFORM_KERNEL 1903 +ENV DRONE_PLATFORM_KERNEL ltsc2022 ADD release/windows/amd64/drone-runner-docker.exe C:/drone-runner-docker.exe -ENTRYPOINT [ "C:\\drone-runner-docker.exe" ] \ No newline at end of file +ENTRYPOINT [ "C:\\drone-runner-docker.exe" ] diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 2cd48bd..ca3136e 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -17,29 +17,11 @@ manifests: variant: v8 architecture: arm64 os: linux - - - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm - platform: - variant: v7 - architecture: arm - os: linux - - - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm - platform: - variant: v6 - architecture: arm - os: linux - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-ppc64le platform: architecture: ppc64le os: linux - - - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64 - platform: - architecture: amd64 - os: windows - version: 1803 - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 platform: @@ -47,14 +29,8 @@ manifests: os: windows version: 1809 - - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64 - platform: - architecture: amd64 - os: windows - version: 1903 - - - image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64 + image: drone/drone-runner-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64 platform: architecture: amd64 os: windows - version: 1909 + version: ltsc2022 \ No newline at end of file diff --git a/scripts/windows/latest.ps1 b/scripts/windows/latest.ps1 deleted file mode 100644 index 7970c9b..0000000 --- a/scripts/windows/latest.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -# this script is used by the continuous integration server to -# build and publish the docker image for a commit to master. - -$env:GOOS="windows" -$env:GOARCH="amd64" -$env:CGO_ENABLED="0" - -if (-not (Test-Path env:VERSION)) { - $env:VERSION="1809" -} - -echo $env:GOOS -echo $env:GOARCH -echo $env:VERSION - -# build the binary -go build -o release/windows/amd64/drone-runner-docker.exe - -# build and publish the docker image -docker login -u $env:USERNAME -p $env:PASSWORD -docker build -f docker/Dockerfile.windows.amd64.$env:VERSION -t drone/drone-runner-docker:windows-$env:VERSION-amd64 . -docker push drone/drone-runner-docker:windows-$env:VERSION-amd64 - -# remove images from local cache -docker rmi drone/drone-runner-docker:windows-$env:VERSION-amd64 diff --git a/scripts/windows/tag.ps1 b/scripts/windows/tag.ps1 deleted file mode 100644 index 6da510d..0000000 --- a/scripts/windows/tag.ps1 +++ /dev/null @@ -1,51 +0,0 @@ -# this script is used by the continuous integration server to -# build and publish the docker image for a tagged revsision. - -$env:GOOS="windows" -$env:GOARCH="amd64" -$env:CGO_ENABLED="0" - -if (-not (Test-Path env:VERSION)) { - $env:VERSION="1809" -} - -if (-not (Test-Path env:DRONE_SEMVER_SHORT)) { - echo "missing semver" - exit 1 -} - -# define the image tags -$env:IMAGE_PATCH="drone/drone-runner-docker:$env:DRONE_SEMVER_SHORT-windows-$env:VERSION-amd64" -$env:IMAGE_MAJOR="drone/drone-runner-docker:$env:DRONE_SEMVER_MAJOR-windows-$env:VERSION-amd64" -$env:IMAGE_MINOR="drone/drone-runner-docker:$env:DRONE_SEMVER_MAJOR.$env:DRONE_SEMVER_MINOR-windows-$env:VERSION-amd64" - -echo "build environment:" -echo $env:GOOS -echo $env:GOARCH -echo $env:VERSION - -# build the binary -go build -o release/windows/amd64/drone-runner-docker.exe - -# authenticate with the docker registry -docker login -u $env:USERNAME -p $env:PASSWORD - -echo "building images:" -echo $env:IMAGE_PATCH -echo $env:IMAGE_MINOR -echo $env:IMAGE_MAJOR - -# build and tag the docker images -docker build -f docker/Dockerfile.windows.amd64.$env:VERSION -t $env:IMAGE_PATCH . -docker tag $env:IMAGE_PATCH $env:IMAGE_MAJOR -docker tag $env:IMAGE_PATCH $env:IMAGE_MINOR - -# publish the docker images -docker push $env:IMAGE_MAJOR -docker push $env:IMAGE_MINOR -docker push $env:IMAGE_PATCH - -# remove images after from local cache -docker rmi $env:IMAGE_MAJOR -docker rmi $env:IMAGE_MINOR -docker rmi $env:IMAGE_PATCH