Skip to content
Open
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
32 changes: 23 additions & 9 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,34 @@ jobs:
build-test:
name: Build Debos and run tests
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- linux/arm64
- linux/amd64
- linux/386
fail-fast: false
steps:
- name: Repository checkout
uses: actions/checkout@v2

- name: Build container
run: |
docker build -f docker/Dockerfile -t godebos/debos .
- name: Setup QEMU
uses: docker/setup-qemu-action@v1

- name: Setup buildx
id: build
uses: docker/setup-buildx-action@v1

- name: Build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: docker/Dockerfile
platforms: ${{ matrix.platform }}
push: false

- name: Run unit tests
- name: Unit Test
run: |
docker-compose -f docker/unit-tests.test.yml \
up --build --exit-code-from=sut
Expand All @@ -22,8 +41,3 @@ jobs:
run: |
docker-compose -f docker/recipes.test.yml \
up --build --exit-code-from=sut

- name: Run test recipes using UML backend
run: |
docker-compose -f docker/recipes-test-uml.yml \
up --build --exit-code-from=sut
5 changes: 3 additions & 2 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ type CommonContext struct {

type DebosContext struct {
*CommonContext
RecipeDir string
Architecture string
RecipeDir string
Architecture string
HostArchitecture string
}

type Action interface {
Expand Down
2 changes: 1 addition & 1 deletion actions/debootstrap_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (d *DebootstrapAction) Run(context *debos.DebosContext) error {
}

/* FIXME drop the hardcoded amd64 assumption" */
foreign := context.Architecture != "amd64"
foreign := context.Architecture != context.HostArchitecture

if foreign {
cmdline = append(cmdline, "--foreign")
Expand Down
3 changes: 2 additions & 1 deletion actions/recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ actions:
}

func runTestWithSubRecipes(t *testing.T, test testSubRecipe, templateVars ...map[string]string) actions.Recipe {
context := debos.DebosContext { &debos.CommonContext{}, "", "" }
context := debos.DebosContext {
CommonContext: &debos.CommonContext{}, RecipeDir: "", Architecture: "", HostArchitecture: "" }
dir, err := ioutil.TempDir("", "go-debos")
assert.Empty(t, err)
defer os.RemoveAll(dir)
Expand Down
36 changes: 35 additions & 1 deletion cmd/debos/debos.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"os"
"path"
"runtime"
"strings"

"github.com/docker/go-units"
Expand Down Expand Up @@ -55,9 +56,36 @@ func warnLocalhost(variable string, value string) {
}
}

func getHostArchitecture() (string, error) {
var arch string
switch runtime.GOARCH {
case "386":
arch = "i386"
case "amd64":
arch = "amd64"
case "arm":
arch = "armhf"
case "arm64":
arch = "arm64"
case "ppc64":
arch = "ppc64el"
case "mips":
arch = "mips"
case "mipsle":
arch = "mipsel"
case "mips64":
arch = "mips64"
case "s390x":
arch = "s390x"
default:
return "", fmt.Errorf("Unsupported CPU architecture %s", runtime.GOARCH)
}
return arch, nil
}

func main() {
context := debos.DebosContext { &debos.CommonContext{}, "", "" }
context := debos.DebosContext {
CommonContext: &debos.CommonContext{}, RecipeDir: "", Architecture: "", HostArchitecture: "" }
var options struct {
Backend string `short:"b" long:"fakemachine-backend" description:"Fakemachine backend to use" default:"auto"`
ArtifactDir string `long:"artifactdir" description:"Directory for packed archives and ostree repositories (default: current directory)"`
Expand Down Expand Up @@ -200,6 +228,12 @@ func main() {
context.Origins["recipe"] = context.RecipeDir

context.Architecture = r.Architecture
context.HostArchitecture, err = getHostArchitecture()
if err != nil {
log.Printf("Unable to determine host architecture: %v\n", err)
exitcode = 1
return
}

context.State = debos.Success

Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ WORKDIR $GOPATH/src/github.com/stretchr/testify
RUN git clone --depth 1 --branch v1.3.0 https://github.com/stretchr/testify . && \
GO111MODULE=on go get ./...

# Build debos
# Temporary fix to make thigns build
WORKDIR $GOPATH/src/github.com/go-debos/fakemachine
RUN git clone --depth 1 --branch eds/portability https://github.com/eds-collabora/fakemachine . && go get -t ./...

COPY . $GOPATH/src/github.com/go-debos/debos
WORKDIR $GOPATH/src/github.com/go-debos/debos/cmd/debos
RUN go get -t ./...
Expand Down Expand Up @@ -77,7 +80,6 @@ RUN echo "deb http://deb.debian.org/debian experimental main" > /etc/apt/sources
pigz \
libostree-1-1 \
libslirp-helper \
linux-image-amd64 \
openssh-client \
parted \
pkg-config \
Expand All @@ -86,7 +88,6 @@ RUN echo "deb http://deb.debian.org/debian experimental main" > /etc/apt/sources
systemd-container \
u-boot-tools \
unzip \
user-mode-linux \
xfsprogs \
xz-utils \
zip && \
Expand Down