Skip to content

Commit

Permalink
try pushing image to ghcr.io
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinran committed Mar 13, 2022
1 parent b7bd3e6 commit 2f7ad5a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
name: test

on: [pull_request, push, workflow_dispatch]
on: [pull_request, workflow_dispatch]

concurrency:
group: test-${{github.ref}}
cancel-in-progress: true

jobs:
image:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2

- name: push image
run: GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}} make push-image

test:
runs-on: ubuntu-latest
needs: image
# To create and push new image: make push-image
container: docker://merlinran/acorn_docker:latest
container: ghcr.io/twisted-fields/acorn_docker:latest
strategy:
fail-fast: true

Expand All @@ -19,7 +29,7 @@ jobs:
uses: actions/checkout@v2

- name: Run tests
run: coverage run -m pytest
run: make test

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN apt update && apt install -y libffi-dev \
bash \
iputils-ping
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install wheel certifi==2020.06.20 pytest coverage[toml]
RUN python3 -m pip install wheel certifi==2020.06.20 pytest~=7.0.1 coverage[toml]~=6.3.2
COPY server/requirements.txt /install/server/
RUN python3 -m pip install -r /install/server/requirements.txt
COPY vehicle/requirements.txt /install/vehicle/
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LOCAL_IMAGE = acorn_docker:1.0
REMOTE_IMAGE = merlinran/acorn_docker
REMOTE_IMAGE = ghcr.io/twisted-fields/acorn_docker:latest
ACORN_NAMES ?= simulation-1

.PHONY: list
Expand Down Expand Up @@ -40,8 +40,12 @@ docker-test: docker-image
@docker-compose -f docker-compose-test.yml up --remove-orphans -d && \
docker exec -it acorn_vehicle make test

.PHONY: push-image # Build and push image to Docker Hub to be used by CI.
push-image: docker-image
.PHONY: push-image # Build and push image to GitHub Container Registry to be used by CI.
push-image:
echo $(GITHUB_TOKEN) | docker login ghcr.io -u twisted-fields --password-stdin && make do-push-image

.PHONY: do-push-image
do-push-image: docker-image
ifeq ($(shell uname -m),arm64)
docker buildx build -t $(REMOTE_IMAGE) --platform linux/amd64,linux/arm64 --push .
else
Expand All @@ -50,7 +54,7 @@ endif

.PHONY: test # Run tests on Linux (if the Python dependencies are installed) or inside Docker. Otherwise, you probably want to try `make docker-test` instead.
test:
coverage run -m pytest --log-cli-level DEBUG && coverage report --skip-covered --skip-empty
python3 -m coverage run -m pytest --log-cli-level DEBUG && python3 -m coverage report --skip-covered --skip-empty

.PHONY: docker-vehicle
docker-vehicle: docker-image
Expand Down
4 changes: 4 additions & 0 deletions vehicle/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ click
coloredlogs
csaps
rpi_ws281x
geopy
psutil
evdev
fibre

0 comments on commit 2f7ad5a

Please sign in to comment.