(maint) move to harness.drone.io (#48)

This commit is contained in:
TP Honey 2023-01-04 10:25:17 +00:00 committed by GitHub
parent 8070857203
commit f03006262c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 132 additions and 428 deletions

View File

@ -1,130 +0,0 @@
# this starlark script should be used to generate the .drone.yml
# configuration file.
def main(ctx):
# TODO consider running unit tests before building and
# publishing docker images.
before = {}
stages = [
linux('arm'),
linux('arm64'),
linux('amd64'),
windows('1903'),
windows('1809'),
]
after = manifest()
# the after stage should only execute after all previous
# stages complete. this builds the dependency graph.
for stage in stages:
after['depends_on'].append(stage['name'])
return stages + [ after ]
# create a pipeline stage responsible for building and
# publishing the Docker image on linux.
def linux(arch):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'linux-%s' % arch,
'platform': {
'os': 'linux',
'arch': arch,
},
'steps': [
{
'name': 'build',
'image': 'golang:1.10',
'commands': [
'cd posix',
'tar -xf fixtures.tar -C /',
'go test -v',
],
},
{
'name': 'publish',
'image': 'plugins/docker',
'settings': {
'auto_tag': 'true',
'auto_tag_suffix': 'linux-%s' % arch,
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
'password': {
'from_secret': 'docker_password',
},
'repo': 'drone/git',
'username': 'drone',
},
'when': {
'event': ['push', 'tag']
}
}
]
}
# create a pipeline stage responsible for building and
# publishing the Docker image on windows. The windows stage
# uses an ssh runner, as opposed to a docker runner.
def windows(version):
return {
'kind': 'pipeline',
'type': 'ssh',
'name': 'windows-%s-amd64' % version,
'platform': {
'os': 'windows'
},
'server': {
'host': { 'from_secret': 'windows_server_%s' % version },
'user': { 'from_secret': 'windows_username' },
'password': { 'from_secret': 'windows_password' },
},
'steps': [
{
'name': 'build',
'environment': {
'USERNAME': { 'from_secret': 'docker_username' },
'PASSWORD': { 'from_secret': 'docker_password' },
},
# TODO these commands build and publish the latest
# docker tag regardless of git tag.
'commands': [
'docker login -u $env:USERNAME -p $env:PASSWORD',
'docker build -f docker/Dockerfile.windows.%s -t drone/git:windows-%s-amd64 .' % (version, version),
'docker push drone/git:windows-%s-amd64' % version,
],
},
],
'trigger': {
'event': ['push']
}
}
# create a pipeline stage responsible for creating and
# publishing a docker manifest to the registry.
def manifest():
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'manifest',
'steps': [
{
'name': 'manifest',
'image': 'plugins/manifest',
'settings': {
'auto_tag': 'true',
'username': 'drone',
'password': {
'from_secret': 'docker_password'
},
'spec': 'docker/manifest.tmpl',
'ignore_missing': 'true',
},
},
],
'depends_on': [],
'trigger': {
'event': ['push', 'tag']
}
}

View File

@ -1,23 +1,24 @@
--- ---
# this file is automatically generated. DO NOT EDIT
kind: pipeline kind: pipeline
type: docker type: vm
name: linux-amd64 name: linux-amd64
platform: platform:
arch: amd64
os: linux os: linux
arch: amd64
pool:
use: ubuntu
steps: steps:
- name: build - name: build
image: golang:1.10 image: golang:1.10
commands: commands:
- cd posix - cd posix
- tar -xf fixtures.tar -C / - tar -xf fixtures.tar -C /
- go test -v - go test -v
- name: publish - name: publish
image: plugins/docker:18 image: plugins/docker:18
settings: settings:
dockerfile: docker/Dockerfile.linux.amd64 dockerfile: docker/Dockerfile.linux.amd64
@ -35,22 +36,25 @@ steps:
--- ---
kind: pipeline kind: pipeline
type: docker type: vm
name: linux-arm64 name: linux-arm64
platform: platform:
arch: arm64
os: linux os: linux
arch: arm64
pool:
use: ubuntu_arm64
steps: steps:
- name: build - name: build
image: golang:1.10 image: golang:1.10
commands: commands:
- cd posix - cd posix
- tar -xf fixtures.tar -C / - tar -xf fixtures.tar -C /
- go test -v - go test -v
- name: publish - name: publish
image: plugins/docker:18 image: plugins/docker:18
settings: settings:
dockerfile: docker/Dockerfile.linux.arm64 dockerfile: docker/Dockerfile.linux.arm64
@ -68,64 +72,30 @@ steps:
--- ---
kind: pipeline kind: pipeline
type: docker type: vm
name: linux-arm name: windows-1809
platform: platform:
arch: arm os: windows
os: linux arch: amd64
pool:
use: windows
steps: steps:
- name: build - name: docker
image: golang:1.10 image: plugins/docker
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: publish
image: plugins/docker:18
settings: settings:
dockerfile: docker/Dockerfile.linux.arm dockerfile: docker/Dockerfile.windows.1809
repo: drone/git repo: drone/git:windows-1809-amd64
auto_tag: "true"
auto_tag_suffix: linux-arm
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
when: auto_tag: true
event: auto_tag_suffix: windows-1809-amd64
- push daemon_off: true
- tag purge: false
---
kind: pipeline
type: ssh
name: windows-1909-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1909
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1909 -t drone/git:windows-1909-amd64 .
- docker push drone/git:windows-1909-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger: trigger:
event: event:
@ -133,31 +103,30 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: ssh type: vm
name: windows-1903-amd64 name: windows-ltsc2022
platform: platform:
os: windows os: windows
arch: amd64
server: pool:
host: use: windows
from_secret: windows_server_1903
password:
from_secret: windows_password
user:
from_secret: windows_username
steps: steps:
- name: build - name: docker
commands: image: plugins/docker
- docker login -u $env:USERNAME -p $env:PASSWORD settings:
- docker build -f docker/Dockerfile.windows.1903 -t drone/git:windows-1903-amd64 . dockerfile: docker/Dockerfile.windows.ltsc2022
- docker push drone/git:windows-1903-amd64 repo: drone/git:windows-ltsc2022-amd64
environment: username:
USERNAME:
from_secret: docker_username from_secret: docker_username
PASSWORD: password:
from_secret: docker_password from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-ltsc2022-amd64
daemon_off: true
purge: false
trigger: trigger:
event: event:
@ -165,43 +134,18 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: ssh type: vm
name: windows-1809-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1809
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1809 -t drone/git:windows-1809-amd64 .
- docker push drone/git:windows-1809-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: docker
name: manifest name: manifest
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps: steps:
- name: manifest - name: manifest
image: plugins/manifest image: plugins/manifest
settings: settings:
auto_tag: "true" auto_tag: "true"
@ -218,9 +162,7 @@ trigger:
- tag - tag
depends_on: depends_on:
- linux-amd64 - linux-amd64
- linux-arm64 - linux-arm64
- linux-arm - windows-1809
- windows-1909-amd64 - windows-ltsc2022
- windows-1903-amd64
- windows-1809-amd64

View File

@ -1,11 +0,0 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,11 +0,0 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,11 +0,0 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,11 +0,0 @@
FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,20 +0,0 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1903 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1903
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

View File

@ -1,20 +0,0 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1909 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1909
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

View File

@ -1,13 +1,13 @@
# escape=` # escape=`
FROM mcr.microsoft.com/windows/servercore:1803 AS git FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; ` Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git; Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1803 FROM mcr.microsoft.com/powershell:nanoserver-ltsc2022
COPY --from=git /git /git COPY --from=git /git /git
ADD windows/* /bin/ ADD windows/* /bin/

View File

@ -17,24 +17,6 @@ manifests:
variant: v8 variant: v8
architecture: arm64 architecture: arm64
os: linux os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
platform:
architecture: amd64
os: windows
version: 1803
- -
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform: platform:
@ -42,14 +24,8 @@ manifests:
os: windows os: windows
version: 1809 version: 1809
- -
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64 image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
platform: platform:
architecture: amd64 architecture: amd64
os: windows os: windows
version: 1903 version: ltsc2022
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909