Skip to content

Commit

Permalink
support aarch64 development
Browse files Browse the repository at this point in the history
  • Loading branch information
jancajthaml authored Nov 21, 2021
1 parent 015e40e commit 3450378
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 159 deletions.
101 changes: 1 addition & 100 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ workflows:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- compile-armhf:
requires:
- deps
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- compile-arm64:
requires:
- deps
Expand All @@ -69,15 +61,6 @@ workflows:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- package-debian-armhf:
requires:
- compile-armhf
- versions
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- package-debian-arm64:
requires:
- compile-arm64
Expand All @@ -91,7 +74,6 @@ workflows:
requires:
- unit-test
- package-debian-amd64
- package-debian-armhf
- package-debian-arm64
filters:
branches:
Expand Down Expand Up @@ -128,20 +110,13 @@ workflows:
- compile-amd64:
requires:
- deps
- compile-armhf:
requires:
- deps
- compile-arm64:
requires:
- deps
- package-debian-amd64:
requires:
- compile-amd64
- versions
- package-debian-armhf:
requires:
- compile-armhf
- versions
- package-debian-arm64:
requires:
- compile-arm64
Expand All @@ -150,7 +125,6 @@ workflows:
requires:
- unit-test
- package-debian-amd64
- package-debian-armhf
- package-debian-arm64
- blackbox-test-amd64:
requires:
Expand Down Expand Up @@ -343,45 +317,6 @@ jobs:

# -------------------------------------------------------------------------- #

compile-armhf:
executor: go
working_directory: /mnt/ramdisk
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: dependencies-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Compile cnb-rates-import binary
command: |
/mnt/ramdisk/dev/lifecycle/package \
--arch linux/armhf \
--source /mnt/ramdisk/services/cnb-rates-import \
--output /mnt/ramdisk/packaging/bin
no_output_timeout: 5m
- run:
name: Compile cnb-rates-batch binary
command: |
/mnt/ramdisk/dev/lifecycle/package \
--arch linux/armhf \
--source /mnt/ramdisk/services/cnb-rates-batch \
--output /mnt/ramdisk/packaging/bin
no_output_timeout: 5m
- run:
name: Compile cnb-rates-rest binary
command: |
/mnt/ramdisk/dev/lifecycle/package \
--arch linux/armhf \
--source /mnt/ramdisk/services/cnb-rates-rest \
--output /mnt/ramdisk/packaging/bin
no_output_timeout: 5m
- save_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin

# -------------------------------------------------------------------------- #

compile-arm64:
executor: go
working_directory: /home/circleci/project
Expand Down Expand Up @@ -448,33 +383,6 @@ jobs:

# -------------------------------------------------------------------------- #

package-debian-armhf:
executor: debian
working_directory: /mnt/ramdisk
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Package for debian
command: |
VERSION=$(cat /mnt/ramdisk/VERSION)
/mnt/ramdisk/dev/lifecycle/debian \
--arch armhf \
--pkg cnb-rates \
--version ${VERSION} \
--source /mnt/ramdisk/packaging
no_output_timeout: 5m
- save_cache:
key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin

# -------------------------------------------------------------------------- #

package-debian-arm64:
executor: debian
working_directory: /mnt/ramdisk
Expand Down Expand Up @@ -511,14 +419,10 @@ jobs:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
Expand Down Expand Up @@ -589,6 +493,7 @@ jobs:
command: |
export VERSION=v$(cat /home/circleci/project/VERSION)
export META=$(cat /home/circleci/project/META)
export ARCH=amd64
docker-compose up -d bbtest
docker exec -t $(docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py
Expand All @@ -610,14 +515,10 @@ jobs:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-armhf-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- deploy:
Expand Down
46 changes: 23 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

META := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null | sed 's:.*/::')
VERSION := $(shell git fetch --tags --force 2> /dev/null; tags=($$(git tag --sort=-v:refname)) && ([ $${\#tags[@]} -eq 0 ] && echo v0.0.0 || echo $${tags[0]}))
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')

export COMPOSE_DOCKER_CLI_BUILD = 1
export DOCKER_BUILDKIT = 1
Expand All @@ -9,14 +10,13 @@ export COMPOSE_PROJECT_NAME = cnb-rates
.ONESHELL:
.PHONY: arm64
.PHONY: amd64
.PHONY: armhf

.PHONY: all
all: bootstrap sync test package bbtest

.PHONY: package
package:
@$(MAKE) package-amd64
@$(MAKE) package-$(ARCH)
@$(MAKE) bundle-docker

.PHONY: package-%
Expand All @@ -26,19 +26,19 @@ package-%: %

.PHONY: bundle-binaries-%
bundle-binaries-%: %
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm package \
--arch linux/$^ \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-rest \
--output /project/packaging/bin
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm package \
--arch linux/$^ \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-import \
--output /project/packaging/bin
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm package \
--arch linux/$^ \
Expand All @@ -47,7 +47,7 @@ bundle-binaries-%: %

.PHONY: bundle-debian-%
bundle-debian-%: %
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm debian-package \
--version $(VERSION) \
Expand All @@ -64,55 +64,55 @@ bundle-docker:

.PHONY: bootstrap
bootstrap:
@docker-compose build --force-rm go
@ARCH=$(ARCH) docker-compose build --force-rm go

.PHONY: lint
lint:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm lint \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-rest \
|| :
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm lint \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-import \
|| :
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm lint \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-batch \
|| :

.PHONY: sec
sec:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sec \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-rest \
|| :
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sec \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-import \
|| :
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sec \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-batch \
|| :

.PHONY: sync
sync:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sync \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-rest
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sync \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-import
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm sync \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-batch
Expand All @@ -126,32 +126,32 @@ scan:

.PHONY: test
test:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm test \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-rest \
--output /project/reports/unit-tests
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm test \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-import \
--output /project/reports/unit-tests
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm test \
--source /go/src/github.com/jancajthaml-openbank/cnb-rates-batch \
--output /project/reports/unit-tests

.PHONY: release
release:
@docker-compose \
@ARCH=$(ARCH) docker-compose \
run \
--rm release \
--version $(VERSION) \
--token ${GITHUB_RELEASE_TOKEN}

.PHONY: bbtest
bbtest:
@META=$(META) VERSION=$(VERSION) docker-compose up -d bbtest
@docker exec -t $$(docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py
@docker-compose down -v
@ARCH=$(ARCH) META=$(META) VERSION=$(VERSION) docker-compose up -d bbtest
@docker exec -t $$(ARCH=$(ARCH) docker-compose ps -q bbtest) python3 /opt/app/bbtest/main.py
@ARCH=$(ARCH) docker-compose down -v
4 changes: 2 additions & 2 deletions bbtest/helpers/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def default_config():
def get_arch(self):
return {
'x86_64': 'amd64',
'armv7l': 'armhf',
'armv8': 'arm64'
'armv8': 'arm64',
'aarch64': 'arm64'
}.get(platform.uname().machine, 'amd64')

def __init__(self, context):
Expand Down
1 change: 0 additions & 1 deletion dev/lifecycle/debian
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ lifecycle::debian::package() {
echo "[info] (${TARGET_PACKAGE}_${TARGET_ARCHITECTURE}) running dpkg-buildpackage"
local CC=gcc
case ${TARGET_ARCHITECTURE} in
armhf) CC=arm-linux-gnueabihf-gcc ;;
arm64) CC=aarch64-linux-gnu-gcc ;;
*) CC=gcc ;;
esac
Expand Down
Loading

0 comments on commit 3450378

Please sign in to comment.