From 5ec795d702b2f3d5fd9e30f3ef8083d210b92c77 Mon Sep 17 00:00:00 2001 From: Raul Salamanca Date: Tue, 9 Jul 2024 00:40:52 -0400 Subject: [PATCH] ci: change pipeline structure and remove windows builds --- .drone.star | 225 ----------------------------- .drone.yml | 176 ++++++++++++++++++++++ .gitignore | 1 - docker/Dockerfile.windows.1809 | 10 -- docker/Dockerfile.windows.ltsc2022 | 10 -- docker/manifest.tmpl | 12 -- 6 files changed, 176 insertions(+), 258 deletions(-) delete mode 100644 .drone.star create mode 100644 .drone.yml delete mode 100644 docker/Dockerfile.windows.1809 delete mode 100644 docker/Dockerfile.windows.ltsc2022 diff --git a/.drone.star b/.drone.star deleted file mode 100644 index 95f318d..0000000 --- a/.drone.star +++ /dev/null @@ -1,225 +0,0 @@ -def main(ctx): - before = testing(ctx) - - stages = [ - linux(ctx, 'amd64'), - linux(ctx, 'arm64'), - ] - - after = manifest(ctx) - - for b in before: - for s in stages: - s['depends_on'].append(b['name']) - - for s in stages: - for a in after: - a['depends_on'].append(s['name']) - - return before + stages + after - -def testing(ctx): - return [{ - 'kind': 'pipeline', - 'type': 'kubernetes', - 'name': 'testing', - 'platform': { - 'os': 'linux', - 'arch': 'amd64', - }, - 'steps': [ - { - 'name': 'staticcheck', - 'image': 'golang:1.21', - 'pull': 'always', - 'commands': [ - 'go get honnef.co/go/tools/cmd/staticcheck', - 'go run honnef.co/go/tools/cmd/staticcheck ./...', - ], - 'volumes': [ - { - 'name': 'gopath', - 'path': '/go', - }, - ], - }, - { - 'name': 'lint', - 'image': 'golang:1.21', - 'pull': 'always', - 'commands': [ - 'go get golang.org/x/lint/golint', - 'go run golang.org/x/lint/golint -set_exit_status ./...', - ], - 'volumes': [ - { - 'name': 'gopath', - 'path': '/go', - }, - ], - }, - { - 'name': 'vet', - 'image': 'golang:1.21', - 'pull': 'always', - 'commands': [ - 'go vet ./...', - ], - 'volumes': [ - { - 'name': 'gopath', - 'path': '/go', - }, - ], - }, - { - 'name': 'test', - 'image': 'golang:1.21', - 'pull': 'always', - 'commands': [ - 'go test -cover ./...', - ], - 'volumes': [ - { - 'name': 'gopath', - 'path': '/go', - }, - ], - }, - ], - 'volumes': [ - { - 'name': 'gopath', - 'temp': {}, - }, - ], - 'trigger': { - 'ref': [ - 'refs/heads/master', - 'refs/tags/**', - 'refs/pull/**', - ], - }, - }] - -def linux(ctx, arch): - docker = { - 'dockerfile': 'docker/Dockerfile.linux.%s' % (arch), - 'repo': 'lemontech/drone-manifest-ecr', - 'username': { - 'from_secret': 'docker_username', - }, - 'password': { - 'from_secret': 'docker_password', - }, - } - - if ctx.build.event == 'pull_request': - docker.update({ - 'dry_run': True, - 'tags': 'linux-%s' % (arch), - }) - else: - docker.update({ - 'auto_tag': True, - 'auto_tag_suffix': 'linux-%s' % (arch), - }) - - if ctx.build.event == 'tag': - build = [ - 'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-manifest-ecr .' % (ctx.build.ref.replace("refs/tags/v", ""), arch), - ] - else: - build = [ - 'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-manifest-ecr .' % (ctx.build.commit[0:8], arch), - ] - - return { - 'kind': 'pipeline', - 'type': 'kubernetes', - 'name': 'linux-%s' % (arch), - 'platform': { - 'os': 'linux', - 'arch': arch, - }, - 'steps': [ - { - 'name': 'environment', - 'image': 'golang:1.21', - 'pull': 'always', - 'environment': { - 'CGO_ENABLED': '0', - }, - 'commands': [ - 'go version', - 'go env', - ], - }, - { - 'name': 'build', - 'image': 'golang:1.21', - 'pull': 'always', - 'environment': { - 'CGO_ENABLED': '0', - }, - 'commands': build, - }, - { - 'name': 'docker', - 'image': 'plugins/docker', - 'pull': 'always', - 'settings': docker, - }, - ], - 'depends_on': [], - 'trigger': { - 'ref': [ - 'refs/heads/master', - 'refs/tags/**', - 'refs/pull/**', - ], - }, - 'node_selector': { - 'kubernetes.io/arch': arch, - }, - 'tolerations': [ - { - 'key': 'node/arch', - 'operator': 'Equal', - 'value': arch, - 'effect': 'NoSchedule' - }, - ], - } - -def manifest(ctx): - return [{ - 'kind': 'pipeline', - 'type': 'kubernetes', - 'name': 'manifest', - 'steps': [ - { - 'name': 'manifest', - 'image': 'plugins/manifest', - 'pull': 'always', - 'settings': { - 'auto_tag': 'true', - 'username': { - 'from_secret': 'docker_username', - }, - 'password': { - 'from_secret': 'docker_password', - }, - 'spec': 'docker/manifest.tmpl', - 'ignore_missing': 'true', - }, - }, - ], - 'depends_on': [], - 'trigger': { - 'ref': [ - 'refs/heads/master', - 'refs/tags/**', - ], - }, - }] diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1bc595c --- /dev/null +++ b/.drone.yml @@ -0,0 +1,176 @@ +kind: pipeline +type: kubernetes +name: testing + +platform: + os: linux + arch: amd64 + +steps: + - name: lint + image: golang:1.21 + pull: always + commands: + - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + - golangci-lint version + - golangci-lint run + volumes: + - name: gopath + path: "/go" + - name: test + image: golang:1.21 + commands: + - go test -cover ./... + volumes: + - name: gopath + path: "/go" +volumes: + - name: gopath + temp: {} +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +--- +kind: pipeline +type: kubernetes +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: + - name: environment + image: golang:1.21 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.21 + environment: + CGO_ENABLED: "0" + commands: + - go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/amd64/drone-manifest-ecr . + - name: docker + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.linux.amd64 + repo: plugins/manifest + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + auto_tag_suffix: linux-amd64 + when: + ref: + - refs/heads/master + - refs/tags/** + - name: docker-dry-run + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.linux.amd64 + repo: plugins/manifest + dry_run: true + tags: linux-amd64 + when: + ref: + - refs/pull/** +depends_on: + - testing +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +--- +kind: pipeline +type: kubernetes +name: linux-arm64 + +platform: + os: linux + arch: arm64 + +steps: + - name: environment + image: golang:1.21 + pull: always + environment: + CGO_ENABLED: "0" + commands: + - go version + - go env + - name: build + image: golang:1.21 + environment: + CGO_ENABLED: "0" + commands: + - go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/arm64/drone-manifest-ecr . + - name: docker + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.linux.arm64 + repo: plugins/manifest + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + auto_tag_suffix: linux-arm64 + when: + ref: + - refs/heads/master + - refs/tags/** + - name: docker-dry-run + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.linux.arm64 + repo: plugins/manifest + dry_run: true + tags: linux-arm64 + when: + ref: + - refs/pull/** +depends_on: + - testing +trigger: + ref: + - refs/heads/master + - refs/tags/** + - refs/pull/** + +--- +kind: pipeline +type: kubernetes +name: manifest + +platform: + os: linux + arch: amd64 + +steps: + - name: manifest + image: plugins/manifest:linux-amd64 + settings: + auto_tag: "true" + username: + from_secret: docker_username + password: + from_secret: docker_password + spec: docker/manifest.tmpl + ignore_missing: true +depends_on: + - linux-amd64 + - linux-arm64 +trigger: + ref: + - refs/heads/master + - refs/tags/** diff --git a/.gitignore b/.gitignore index 9a8580b..ddd54c2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ /drone-manifest* coverage.out -.drone.yml diff --git a/docker/Dockerfile.windows.1809 b/docker/Dockerfile.windows.1809 deleted file mode 100644 index 262a473..0000000 --- a/docker/Dockerfile.windows.1809 +++ /dev/null @@ -1,10 +0,0 @@ -# escape=` -FROM plugins/base:windows-1809-amd64 - -LABEL maintainer="Drone.IO Community " ` - org.label-schema.name="Drone Manifest" ` - org.label-schema.vendor="Drone.IO Community" ` - org.label-schema.schema-version="1.0" - -ADD release/windows/amd64/drone-manifest-ecr.exe C:/bin/drone-manifest-ecr.exe -ENTRYPOINT [ "C:\\bin\\drone-manifest-ecr.exe" ] diff --git a/docker/Dockerfile.windows.ltsc2022 b/docker/Dockerfile.windows.ltsc2022 deleted file mode 100644 index 52d0d51..0000000 --- a/docker/Dockerfile.windows.ltsc2022 +++ /dev/null @@ -1,10 +0,0 @@ -# escape=` -FROM plugins/base:windows-ltsc2022-amd64 - -LABEL maintainer="Drone.IO Community " ` - org.label-schema.name="Drone Manifest" ` - org.label-schema.vendor="Drone.IO Community" ` - org.label-schema.schema-version="1.0" - -ADD release/windows/amd64/drone-manifest-ecr.exe C:/bin/drone-manifest-ecr.exe -ENTRYPOINT [ "C:\\bin\\drone-manifest-ecr.exe" ] diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 2e05545..cce8876 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -17,15 +17,3 @@ manifests: architecture: arm64 os: linux variant: v8 - - - image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 - platform: - architecture: amd64 - os: windows - version: 1809 - - - image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64 - platform: - architecture: amd64 - os: windows - version: ltsc2022