Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC-1226: Use updated RunCLI interface from tester-utils #44

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17.x
go-version: 1.21.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17.x
go-version: 1.21.x
- run: sudo curl -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/v17/v17_linux_amd64
- run: sudo chmod +x /usr/local/bin/docker-explorer
- run: sudo make test_in_docker_container
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
.DS_Store
.history/
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM golang:1.17-alpine
FROM golang:1.21-alpine

RUN apk add curl
RUN apk add --no-cache --upgrade 'curl>=8.5'

# Download docker-explorer
ARG docker_explorer_version=v18
RUN curl --fail -Lo /usr/local/bin/docker-explorer https://github.com/codecrafters-io/docker-explorer/releases/download/${docker_explorer_version}/${docker_explorer_version}_linux_amd64
RUN chmod +x /usr/local/bin/docker-explorer

# Development deps
RUN apk add make gcc musl-dev git
RUN apk add --no-cache --upgrade 'make>=4.4' 'gcc>=12.2' 'musl-dev>=1.2' 'git>=2.40'

WORKDIR /app
COPY go.mod /app/go.mod
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test:

test_with_docker: build
CODECRAFTERS_SUBMISSION_DIR=$(shell pwd)/internal/test_helpers/pass_all \
CODECRAFTERS_TEST_CASES_JSON="[{"slug":"init","tester_log_prefix":"stage-1","title":"Stage #1: Execute a program"},{"slug":"stdio","tester_log_prefix":"stage-2","title":"Stage #2: Wireup stdout \u0026 stderr"},{"slug":"exit_code","tester_log_prefix":"stage-3","title":"Stage #3: Handle exit codes"},{"slug":"fs_isolation","tester_log_prefix":"stage-4","title":"Stage #4: Filesystem isolation"},{"slug":"process_isolation","tester_log_prefix":"stage-5","title":"Stage #5: Process isolation"},{"slug":"fetch_from_registry","tester_log_prefix":"stage-6","title":"Stage #6: Fetch an image from the Docker Registry"}]" \
CODECRAFTERS_TEST_CASES_JSON="[{"slug":"je9","tester_log_prefix":"stage-1","title":"Stage #1: Execute a program"},{"slug":"kf3","tester_log_prefix":"stage-2","title":"Stage #2: Wireup stdout \u0026 stderr"},{"slug":"cn8","tester_log_prefix":"stage-3","title":"Stage #3: Handle exit codes"},{"slug":"if6","tester_log_prefix":"stage-4","title":"Stage #4: Filesystem isolation"},{"slug":"lu7","tester_log_prefix":"stage-5","title":"Stage #5: Process isolation"},{"slug":"hs1","tester_log_prefix":"stage-6","title":"Stage #6: Fetch an image from the Docker Registry"}]" \
dist/main.out

test_in_docker_container:
Expand Down
21 changes: 17 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
module github.com/codecrafters-io/docker-tester

go 1.13
go 1.21

toolchain go1.22.1

require (
github.com/codecrafters-io/tester-utils v0.2.21
github.com/fatih/color v1.16.0 // indirect
github.com/codecrafters-io/tester-utils v0.2.24
github.com/stretchr/testify v1.8.4
golang.org/x/sys v0.19.0 // indirect
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/sys v0.20.0 // indirect
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ github.com/codecrafters-io/tester-utils v0.2.20 h1:t/IFFXOrSgRIoq6x4kUnRdjuai7Ec
github.com/codecrafters-io/tester-utils v0.2.20/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.21 h1:eVq/23WocZMCFnNPiB6rgP/4FZ/tlLoijT2EulkOng4=
github.com/codecrafters-io/tester-utils v0.2.21/go.mod h1:BeSLyqBpFxUwIm41QlnuRG7ZsabBXWE2Ga3LMFUXAPM=
github.com/codecrafters-io/tester-utils v0.2.24 h1:8IwKd70n9BMfVqNoGxRJItFj769p6h6LxCx4OMwWoq8=
github.com/codecrafters-io/tester-utils v0.2.24/go.mod h1:VgP0WmmRsA8L1urWGMXPW4Zv5jcwHwR0LdKZ8ZAEFT4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand Down Expand Up @@ -50,6 +54,8 @@ golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
10 changes: 1 addition & 9 deletions internal/cli.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
package internal

import (
"fmt"
testerutils "github.com/codecrafters-io/tester-utils"
)

func RunCLI(env map[string]string) int {
tester, err := testerutils.NewTester(env, testerDefinition)

if err != nil {
fmt.Printf("%s", err)
return 1
}

return tester.RunCLI()
return testerutils.RunCLI(env, testerDefinition)
}
Loading