Skip to content

Commit

Permalink
Merge pull request #136 from phillipsj/feature/fix-binary-publish
Browse files Browse the repository at this point in the history
Migrating the build to mage and fixing the binary location issue.
  • Loading branch information
phillipsj authored Jul 26, 2022
2 parents 927f3b4 + 134e74d commit db111a7
Show file tree
Hide file tree
Showing 21 changed files with 276 additions and 1,334 deletions.
68 changes: 30 additions & 38 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@ platform:

steps:
- name: build
image: plugins/docker
pull: always
settings:
dry_run: true
purge: true
build_args:
- SERVERCORE_VERSION=1809
- ARCH=amd64
- ACTION=ci
- [email protected] [email protected]
- REPO=https://github.com/rancher/wins
custom_dns: 1.1.1.1
dockerfile: Dockerfile
repo: rancher/wins
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
image: golang:1.18-windowsservercore
environment:
MAGEFILE_CACHE: C:/Drone/.magefile
commands:
- go install github.com/golangci/golangci-lint/cmd/[email protected]
- go install github.com/onsi/ginkgo/ginkgo@latest
- go get -u github.com/onsi/gomega/...
- cd ..
- git clone https://github.com/magefile/mage.git
- cd mage
- go run bootstrap.go install
- cd C:/Drone/src
- mage ci

- name: publish
image: plugins/docker
Expand All @@ -35,8 +31,6 @@ steps:
build_args:
- SERVERCORE_VERSION=1809
- ARCH=amd64
- VERSION=${DRONE_TAG}
- ACTION=ci
- [email protected] [email protected]
- REPO=https://github.com/rancher/wins
custom_dns: 1.1.1.1
Expand Down Expand Up @@ -68,9 +62,12 @@ steps:
- sha256
- sha512
files:
- C:\\wins.exe
- C:/wins.exe
file_exists:
- fail
volumes:
- name: root
path: C:/
when:
instance:
- drone-publish.rancher.io
Expand Down Expand Up @@ -109,22 +106,19 @@ steps:
image: rancher/drone-images:git-amd64-ltsc2022

- name: build
image: rancher/drone-images:docker-amd64-ltsc2022
settings:
dry_run: true
purge: true
build_args:
- SERVERCORE_VERSION=ltsc2022
- ARCH=amd64
- ACTION=ci
- [email protected] [email protected]
- REPO=https://github.com/rancher/wins
custom_dns: 1.1.1.1
dockerfile: Dockerfile
repo: rancher/wins
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
image: golang:1.18-windowsservercore
environment:
MAGEFILE_CACHE: C:/Drone/.magefile
commands:
- go install github.com/golangci/golangci-lint/cmd/[email protected]
- go install github.com/onsi/ginkgo/ginkgo@latest
- go get -u github.com/onsi/gomega/...
- cd ..
- git clone https://github.com/magefile/mage.git
- cd mage
- go run bootstrap.go install
- cd C:/Drone/src
- mage ci


- name: publish
Expand All @@ -134,8 +128,6 @@ steps:
build_args:
- SERVERCORE_VERSION=ltsc2022
- ARCH=amd64
- VERSION=${DRONE_TAG}
- ACTION=ci
- [email protected] [email protected]
- REPO=https://github.com/rancher/wins
custom_dns: 1.1.1.1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ Dockerfile.dapper[0-9]*

dist/
*.tgz

artifacts/
71 changes: 1 addition & 70 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,73 +1,4 @@
ARG SERVERCORE_VERSION
FROM library/golang:1.17.7 as base
SHELL ["powershell", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN pushd c:\; \
$URL = 'https://github.com/StefanScherer/docker-cli-builder/releases/download/20.10.5/docker.exe'; \
Write-Host ('Downloading docker from {0} ...' -f $URL); \
curl.exe -sfL $URL -o c:\Windows\docker.exe; \
Write-Host 'docker install complete.'; \
popd;

RUN pushd c:\ ; \
$URL = 'https://github.com/cli/cli/releases/download/v2.14.2/gh_2.14.2_windows_amd64.zip' ; \
Write-Host ('Downloading github cli from {0} ...' -f $URL); \
curl.exe -sfL $URL -o c:\gh.zip; \
Write-Host 'Expanding ...'; \
Expand-Archive -Path c:\gh.zip -DestinationPath c:\gh_2.14.2_windows_amd64; \
Write-Host 'Cleaning ...'; \
Remove-Item -Force -Recurse -Path c:\gh.zip; \
Write-Host 'Updating PATH ...'; \
[Environment]::SetEnvironmentVariable('PATH', ('c:\gh_2.14.2_windows_amd64\bin\;{0}' -f $env:PATH), [EnvironmentVariableTarget]::Machine); \
Write-Host 'github cli install complete.'; \
popd

RUN pushd c:\; \
$URL = 'https://github.com/golangci/golangci-lint/releases/download/v1.44.0/golangci-lint-1.44.0-windows-amd64.zip'; \
Write-Host ('Downloading golangci from {0} ...' -f $URL); \
curl.exe -sfL $URL -o c:\golangci-lint.zip; \
Write-Host 'Expanding ...'; \
Expand-Archive -Path c:\golangci-lint.zip -DestinationPath c:\; \
Write-Host 'Cleaning ...'; \
Remove-Item -Force -Recurse -Path c:\golangci-lint.zip; \
Write-Host 'Updating PATH ...'; \
[Environment]::SetEnvironmentVariable('PATH', ('c:\golangci-lint-1.44.0-windows-amd64\;{0}' -f $env:PATH), [EnvironmentVariableTarget]::Machine); \
Write-Host 'golangci-lint install complete.'; \
popd;

# upgrade git
RUN pushd c:\; \
$URL = 'https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/MinGit-2.33.0.2-64-bit.zip'; \
Write-Host ('Downloading git from {0} ...' -f $URL); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -UseBasicParsing -OutFile c:\git.zip -Uri $URL; \
Write-Host 'Expanding ...'; \
Expand-Archive -Force -Path c:\git.zip -DestinationPath c:\git\.; \
Write-Host 'Cleaning ...'; \
Remove-Item -Force -Recurse -Path c:\git.zip; \
Write-Host 'git install complete.'; \
popd;

# install ginkgo
RUN pushd c:\; \
Write-Host ('Updating ginkgo ...'); \
go install github.com/onsi/ginkgo/ginkgo@latest; \
go get -u github.com/onsi/gomega/...; \
Write-Host 'Ginkgo install complete.'; \
popd;

COPY . /go/wins/
WORKDIR C:/

ARG ACTION
ARG DRONE_TAG
ENV DRONE_TAG ${DRONE_TAG}

ENV ACTION ${ACTION}
RUN Write-Host "Starting CI Action ($env:ACTION) for wins"; \
Set-Location C:/go/wins/ ; \
./scripts/ci.ps1 "$env:ACTION"

FROM mcr.microsoft.com/windows/servercore:${SERVERCORE_VERSION} as wins
ARG VERSION
ARG MAINTAINERS
Expand All @@ -88,7 +19,7 @@ LABEL org.opencontainers.image.vendor="Rancher Labs"
LABEL org.opencontainers.image.version=${VERSION}
WORKDIR C:/

COPY --from=base C:/package/ C:/
COPY ./artifacts C:/
# staging for backwards compatibility
# Create a symbolic link pwsh.exe that points to powershell.exe for consistency
RUN New-Item -ItemType SymbolicLink -Target "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Path "C:\Windows\System32\WindowsPowerShell\v1.0\pwsh.exe" ; \
Expand Down
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,10 @@ tls-config:

## Build

``` powershell
# Build inside a Docker container
> .\make.ps1 build
# Build using Powershell scripts only
This project uses magefile to build. The default target is build.

> .\make.ps1 no-docker build
# Build locally using drone (Docker-In-Docker)
> drone.exe exec --trusted --pipeline=windows-1809 --include=build --event=pull_request --ref="$(git rev-parse --short HEAD)" --sha="$(git show -s --format=%H)" .drone.yml
``` powershell
> go run mage.go <target>
```

## Testing
Expand All @@ -236,13 +228,13 @@ and integration test.
For validation test, which could be embedded into a containerized CI flow, please run the below command in `PowerShell`:

``` powershell
> .\make.ps1 validate
> go run mage.go validate
```

For integration test, please run the below command in `PowerShell`:

``` powershell
> .\make.ps1 integration
> go run mage.go integration
```

> Note: Don't use `bin/wins.exe` after integration testing. Please `.\make.ps1 build` again.
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ require (

)

require github.com/magefile/mage v1.13.0

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
Expand Down Expand Up @@ -98,6 +100,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.20.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
Expand All @@ -113,7 +116,7 @@ require (
github.com/urfave/cli v1.22.9 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.3.7 // indirect
Expand All @@ -122,6 +125,7 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
10 changes: 8 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/lpabon/godbc v0.1.1/go.mod h1:Jo9QV0cf3U6jZABgiJ2skINAXb9j8m51r07g4KI92ZA=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/magefile/mage v1.13.0 h1:XtLJl8bcCM7EFoO8FyH8XK3t7G5hQAeK+i4tq+veT9M=
github.com/magefile/mage v1.13.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
Expand Down Expand Up @@ -701,7 +703,6 @@ github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE=
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nishanths/exhaustive v0.2.3/go.mod h1:bhIX678Nx8inLM9PbpvK1yv6oGtoP8BfaIeMzgBNKvc=
github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ=
Expand Down Expand Up @@ -732,6 +733,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q=
github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
Expand Down Expand Up @@ -1147,6 +1150,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ=
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 h1:zwrSfklXn0gxyLRX/aR+q6cgHbV/ItVyzbPlbA+dkAw=
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4=
Expand Down Expand Up @@ -1558,8 +1563,9 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
Expand Down
Loading

0 comments on commit db111a7

Please sign in to comment.