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

Add arm64 support / arm64 artifact generation / enable-execute-command #1

Merged
merged 19 commits into from
Nov 2, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="ubuntu-22.04"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>


29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": { "VARIANT": "ubuntu-22.04" }
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
//"workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/aws/amazon-ecs-cli,type=bind",
//"workspaceFolder": "/go/src/github.com/aws/amazon-ecs-cli",
"features": {
"git": "os-provided",
"aws-cli": "latest",
"ghcr.io/devcontainers/features/go:1": {
"version": "1.13"
}
}
}
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go build / go test

on: push

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.13

- name: Build
run: make build

- name: Test
run: make test

- name: Build for supported platforms
run: make supported-platforms

- name: Archive mac amd64 artifact
uses: actions/upload-artifact@v3
with:
name: ecs-cli-darwin-amd64-${{ github.sha }}
path: bin/darwin-amd64/ecs-cli

- name: Archive linux amd64 artifact
uses: actions/upload-artifact@v3
with:
name: ecs-cli-linux-amd64-${{ github.sha }}
path: bin/linux-amd64/ecs-cli

- name: Archive linux arm64 artifact
uses: actions/upload-artifact@v3
with:
name: ecs-cli-linux-arm64-${{ github.sha }}
path: bin/linux-arm64/ecs-cli

- name: build Release artifacts
run: make release
if: startsWith(github.ref, 'refs/tags/')

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files:
./*.tgz
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ecs-cli/vendor/pkg
ecs-cli/.vscode/*
ecs-cli/.idea
.idea/*
vendor
79 changes: 51 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,34 @@ ROOT := $(shell pwd)

all: build

SOURCEDIR := ./ecs-cli
SOURCEDIR := .
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
VERSION := $(shell cat VERSION)
LOCAL_BINARY := bin/local/ecs-cli
LINUX_BINARY := bin/linux-amd64/ecs-cli
DARWIN_BINARY := bin/darwin-amd64/ecs-cli
WINDOWS_BINARY := bin/windows-amd64/ecs-cli.exe
LINUX_AMD_DIR := bin/linux-amd64
LINUX_AMD_BINARY := $(LINUX_AMD_DIR)/ecs-cli
LINUX_AMD_ARCHIVE := ecs-cli-linux-amd64-$(VERSION).tgz
LINUX_ARM_DIR := bin/linux-arm64
LINUX_ARM_BINARY := $(LINUX_ARM_DIR)/ecs-cli
LINUX_ARM_ARCHIVE := ecs-cli-linux-arm64-$(VERSION).tgz
DARWIN_AMD_DIR := bin/darwin-amd64
DARWIN_AMD_BINARY := $(DARWIN_AMD_DIR)/ecs-cli
DARWIN_AMD_ARCHIVE := ecs-cli-linux-darwin-amd64-$(VERSION).tgz
WINDOWS_DIR := windows-amd64
WINDOWS_BINARY := $(WINDOWS_DIR)/ecs-cli.exe
LOCAL_PATH := $(ROOT)/scripts:${PATH}
DEP_RELEASE_TAG := v0.5.4
GO_RELEASE_TAG := 1.13

.PHONY: build
build: $(LOCAL_BINARY)

$(LOCAL_BINARY): $(SOURCES)
$(LOCAL_BINARY): $(SOURCES) VERSION
./scripts/build_binary.sh ./bin/local
@echo "Built ecs-cli"

.PHONY: test
test:
go mod vendor
env -i PATH=$$PATH GOPATH=$$(go env GOPATH) GOROOT=$$(go env GOROOT) GOCACHE=$$(go env GOCACHE) \
go test -race -timeout=120s -cover ./ecs-cli/modules/...

Expand Down Expand Up @@ -66,15 +75,11 @@ integ-test-run-with-coverage: integ-test-run

.PHONY: generate
generate: $(SOURCES)
GO111MODULE=on go get github.com/golang/mock/mockgen@v1.4.4
GO111MODULE=on go get golang.org/x/tools/cmd/goimports@release-branch.go1.13
PATH=$(LOCAL_PATH) go mod vendor
PATH=$(LOCAL_PATH) go generate ./ecs-cli/modules/...

.PHONY: generate-deps
generate-deps:
DEP_RELEASE_TAG=$DEP_RELEASE_TAG
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
go get github.com/golang/mock/mockgen
go get golang.org/x/tools/cmd/goimports

.PHONY: windows-build
windows-build: $(WINDOWS_BINARY)

Expand All @@ -84,12 +89,12 @@ docker-build:
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
--env ECS_RELEASE=$(ECS_RELEASE) \
golang:$(GO_RELEASE_TAG) make $(LINUX_BINARY)
golang:$(GO_RELEASE_TAG) make $(LINUX_AMD_BINARY)
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
--env ECS_RELEASE=$(ECS_RELEASE) \
golang:$(GO_RELEASE_TAG) make $(DARWIN_BINARY)
golang:$(GO_RELEASE_TAG) make $(DARWIN_AMD_BINARY)
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
Expand All @@ -105,24 +110,42 @@ docker-test:
golang:$(GO_RELEASE_TAG) make test

.PHONY: supported-platforms
supported-platforms: $(LINUX_BINARY) $(DARWIN_BINARY) $(WINDOWS_BINARY)
supported-platforms: $(DARWIN_AMD_BINARY) $(LINUX_AMD_BINARY) $(LINUX_ARM_BINARY) #$(WINDOWS_BINARY)

.PHONY: release
release: $(LINUX_AMD_ARCHIVE) $(LINUX_ARM_ARCHIVE) $(DARWIN_AMD_ARCHIVE)

$(WINDOWS_BINARY): $(SOURCES)
@mkdir -p ./bin/windows-amd64
TARGET_GOOS=windows GOARCH=amd64 ./scripts/build_binary.sh ./bin/windows-amd64
mv ./bin/windows-amd64/ecs-cli ./bin/windows-amd64/ecs-cli.exe
@echo "Built ecs-cli.exe for windows"
# $(WINDOWS_BINARY): $(SOURCES)
# @mkdir -p ./bin/windows-amd64
# TARGET_GOOS=windows GOARCH=amd64 ./scripts/build_binary.sh ./bin/windows-amd64
# mv ./bin/windows-amd64/ecs-cli ./bin/windows-amd64/ecs-cli.exe
# @echo "Built ecs-cli.exe for windows"

$(LINUX_BINARY): $(SOURCES)
@mkdir -p ./bin/linux-amd64
$(LINUX_AMD_BINARY): $(SOURCES) generate
@mkdir -p $(LINUX_AMD_DIR)
TARGET_GOOS=linux GOARCH=amd64 ./scripts/build_binary.sh ./bin/linux-amd64
@echo "Built ecs-cli for linux"
@echo "Built ecs-cli for linux (amd64)"

$(LINUX_ARM_BINARY): $(SOURCES) generate
@mkdir -p $(LINUX_ARM_DIR)
TARGET_GOOS=linux GOARCH=arm64 ./scripts/build_binary.sh ./bin/linux-arm64
@echo "Built ecs-cli for linux (arm64)"

$(DARWIN_BINARY): $(SOURCES)
@mkdir -p ./bin/darwin-amd64
$(DARWIN_AMD_BINARY): $(SOURCES) generate
@mkdir -p ./bin/$(DARWIN_AMD_DIR)
TARGET_GOOS=darwin GOARCH=amd64 ./scripts/build_binary.sh ./bin/darwin-amd64
@echo "Built ecs-cli for darwin"
@echo "Built ecs-cli for darwin (amd64)"

$(LINUX_AMD_ARCHIVE): $(LINUX_AMD_BINARY)
tar zcv -C $(LINUX_AMD_DIR) -f $(LINUX_AMD_ARCHIVE) ecs-cli

$(LINUX_ARM_ARCHIVE): $(LINUX_ARM_BINARY)
tar zcv -C $(LINUX_ARM_DIR) -f $(LINUX_ARM_ARCHIVE) ecs-cli

$(DARWIN_AMD_ARCHIVE): $(DARWIN_AMD_BINARY)
cd $(DARWIN_AMD_DIR)
tar zcv -C $(DARWIN_AMD_DIR) -f $(DARWIN_AMD_ARCHIVE) ecs-cli

.PHONY: clean
clean:
rm -rf ./bin/ ||:
rm -rf ./bin/ ./vendor||:
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.0
1.22.0-ap
Loading