Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 96f2c4c

Browse files
ammarioNathan Potter
authored and
Nathan Potter
committed
Add CI
1 parent 9d35204 commit 96f2c4c

File tree

8 files changed

+59
-22
lines changed

8 files changed

+59
-22
lines changed

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
language: go
2+
3+
dist: xenial
4+
services:
5+
- docker
6+
7+
go:
8+
- 1.12
9+
10+
go_import_path: go.coder.com/sail
11+
12+
install: true
13+
env:
14+
- GO111MODULE=on
15+
script:
16+
- env
17+
- ci/build.sh
18+
- cat /etc/passwd
19+
- sudo usermod -u 1000 travis
20+
- sudo groupmod -g 1000 travis
21+
- go test -v ./...
22+
23+
deploy:
24+
provider: releases
25+
api_key: "GITHUB OAUTH TOKEN"
26+
file: "bin/sail-linux-amd64"
27+
skip_cleanup: true
28+
draft: true

ci/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ build(){
1818
}
1919

2020
GOOS=darwin build
21-
GOOS=linux build
21+
GOOS=linux build

images/base/Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,23 @@ RUN wget -O /usr/bin/code-server https://codesrv-ci.cdr.sh/latest-linux && \
2727
chmod +x /usr/bin/code-server
2828

2929

30-
ADD installext /usr/bin/installext
30+
ADD installext /usr/bin/installext
31+
32+
# Use fixuid so that we can dynamically change the uid:gid to match what is being used by the host user.
33+
# Note: If the project is large, the `chown -R` call from fixuid can take a long time.
34+
# TODO: optimize the chown for larger projects.
35+
RUN addgroup --gid 1000 user && \
36+
adduser --uid 1000 --ingroup user --home /home/user --shell /bin/sh --disabled-password --gecos "" user && \
37+
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd
38+
39+
RUN USER=user && \
40+
GROUP=user && \
41+
curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.4/fixuid-0.4-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \
42+
chown root:root /usr/local/bin/fixuid && \
43+
chmod 4755 /usr/local/bin/fixuid && \
44+
mkdir -p /etc/fixuid && \
45+
printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml
46+
47+
USER user:user
48+
49+
ENTRYPOINT ["fixuid"]

internal/codeserver/proc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Port(containerName string) (string, error) {
3434
// tcp 0 0 127.0.0.53:domain 0.0.0.0:* LISTEN -
3535
out, err := dockutil.Exec(containerName, "netstat", "-tpl").CombinedOutput()
3636
if err != nil {
37-
return "", xerrors.Errorf("failed to netstat: %s, %w", out, err)
37+
return "", xerrors.Errorf("failed to netstat %s: %w", out, err)
3838
}
3939

4040
lines := strings.Split(string(out), "\n")

project_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ func Test_project(t *testing.T) {
2626
expCustomBldImg bool
2727
}{
2828
{
29-
"ssh",
29+
"https",
3030
"OK",
3131
"codercom/bigdur",
3232
"codercom_bigdur",
3333
false,
3434
true,
3535
},
3636
{
37-
"ssh",
37+
"https",
3838
"RepoNotExist",
3939
"codercom/do-not-exist",
4040
"codercom_do-not-exist",

proxycmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import (
1212
"net/http"
1313
"net/http/httputil"
1414
"net/url"
15-
"nhooyr.io/websocket"
1615
"strconv"
1716
"sync"
1817
"sync/atomic"
1918
"time"
2019

20+
"nhooyr.io/websocket"
21+
2122
"go.coder.com/cli"
2223
"go.coder.com/flog"
2324
"golang.org/x/xerrors"

repo_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/stretchr/testify/require"
88
)
99

10-
func TestParseRepo(t *testing.T) {
10+
func Test_parseRepo(t *testing.T) {
1111
var tests = []struct {
1212
defSchema string
1313
defHost string
@@ -85,17 +85,6 @@ func TestParseRepo(t *testing.T) {
8585
"ssh",
8686
"ssh://[email protected]/cdr/sail.git",
8787
},
88-
// ensure custom host works
89-
{
90-
"https",
91-
"my.private-git.com",
92-
"private/repo",
93-
"private/repo",
94-
"my.private-git.com",
95-
"",
96-
"https",
97-
"https://my.private-git.com/private/repo.git",
98-
},
9988
}
10089

10190
for _, test := range tests {

sail_helpers_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ func requireProjectsNotRunning(t *testing.T, projects ...string) {
129129
}
130130
}
131131

132+
func requireUbuntuDevImage(t *testing.T) {
133+
require.NoError(t, ensureImage("codercom/ubuntu-dev"))
134+
}
135+
132136
func requireGetImageLabels(t *testing.T, image string) map[string]string {
133137
return requireImageInspect(t, image).ContainerConfig.Labels
134138
}
@@ -185,10 +189,6 @@ func requireContainerRemove(t *testing.T, cntName string) {
185189
require.NoError(t, err)
186190
}
187191

188-
func requireUbuntuDevImage(t *testing.T) {
189-
require.NoError(t, ensureImage("codercom/ubuntu-dev"))
190-
}
191-
192192
type rollback struct {
193193
fns []func()
194194
}

0 commit comments

Comments
 (0)