Compare commits

..

3 Commits

Author SHA1 Message Date
Matthew Penner
3546a2c461 docker: add debug logs around Start and Attach 2022-01-24 19:15:15 -07:00
Matthew Penner
68d4fb454f actions(test): fix caching, run tests with race detector 2022-01-24 19:06:14 -07:00
Matthew Penner
136540111d docker: attach to container before starting 2022-01-24 19:01:33 -07:00
4 changed files with 22 additions and 8 deletions

View File

@@ -32,17 +32,20 @@ jobs:
go env go env
printf "\n\nSystem Environment:\n\n" printf "\n\nSystem Environment:\n\n"
env env
printf "Git Version: $(git version)\n\n"
echo "::set-output name=version_tag::${GITHUB_REF/refs\/tags\//}" echo "::set-output name=version_tag::${GITHUB_REF/refs\/tags\//}"
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
echo "::set-output name=go_cache::$(go env GOCACHE)" echo "::set-output name=go_cache::$(go env GOCACHE)"
echo "::set-output name=go_mod_cache::$(go env GOMODCACHE)"
- name: Build Cache - name: Build Cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.env.outputs.go_cache }} key: ${{ runner.os }}-go${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-${{ matrix.go }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: | restore-keys: |
${{ runner.os }}-${{ matrix.go }}-go ${{ runner.os }}-go${{ matrix.go }}-
path: |
${{ steps.env.outputs.go_cache }}
${{ steps.env.outputs.go_mod_cache }}
- name: Get Dependencies - name: Get Dependencies
run: | run: |
go get -v -t -d ./... go get -v -t -d ./...
@@ -56,8 +59,10 @@ jobs:
go build -v -trimpath -ldflags="-s -w -X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o build/wings_${{ matrix.goos }}_${{ matrix.goarch }} wings.go go build -v -trimpath -ldflags="-s -w -X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o build/wings_${{ matrix.goos }}_${{ matrix.goarch }} wings.go
upx build/wings_${{ matrix.goos }}_${{ matrix.goarch }} upx build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
chmod +x build/wings_${{ matrix.goos }}_${{ matrix.goarch }} chmod +x build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
- name: Test - name: Tests
run: go test ./... run: go test ./...
- name: Tests (Race)
run: go test -race ./...
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }} if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }}

View File

@@ -49,10 +49,12 @@ func (e *Environment) Attach(ctx context.Context) error {
if e.IsAttached() { if e.IsAttached() {
return nil return nil
} }
e.log().Debug("not attached to container, continuing with attach...")
if err := e.followOutput(); err != nil { if err := e.followOutput(); err != nil {
return err return err
} }
e.log().Debug("following container output")
opts := types.ContainerAttachOptions{ opts := types.ContainerAttachOptions{
Stdin: true, Stdin: true,
@@ -62,11 +64,13 @@ func (e *Environment) Attach(ctx context.Context) error {
} }
// Set the stream again with the container. // Set the stream again with the container.
e.log().Debug("attempting to attach...")
if st, err := e.client.ContainerAttach(ctx, e.Id, opts); err != nil { if st, err := e.client.ContainerAttach(ctx, e.Id, opts); err != nil {
return err return err
} else { } else {
e.SetStream(&st) e.SetStream(&st)
} }
e.log().Debug("attached!")
go func() { go func() {
// Don't use the context provided to the function, that'll cause the polling to // Don't use the context provided to the function, that'll cause the polling to

View File

@@ -111,14 +111,19 @@ func (e *Environment) Start(ctx context.Context) error {
actx, cancel := context.WithTimeout(ctx, time.Second*30) actx, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel() defer cancel()
if err := e.Attach(actx); err != nil {
return err
}
e.log().Debug("attempting to start container...")
if err := e.client.ContainerStart(actx, e.Id, types.ContainerStartOptions{}); err != nil { if err := e.client.ContainerStart(actx, e.Id, types.ContainerStartOptions{}); err != nil {
return errors.WrapIf(err, "environment/docker: failed to start container") return errors.WrapIf(err, "environment/docker: failed to start container")
} }
e.log().Debug("started container!")
// No errors, good to continue through. // No errors, good to continue through.
sawError = false sawError = false
return nil
return e.Attach(actx)
} }
// Stop stops the container that the server is running in. This will allow up to // Stop stops the container that the server is running in. This will allow up to

View File

@@ -1,3 +1,3 @@
package system package system
var Version = "1.5.6" var Version = "develop"