forked from art049/fastapi-odmantic-realworld-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
111 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# .github/workflows/ci.yml | ||
|
||
name: CI Workflow (earthly) | ||
|
||
on: | ||
push: | ||
branches: | ||
- ci/earthly | ||
|
||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
env: | ||
FORCE_COLOR: 1 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
- name: Install asdf | ||
uses: asdf-vm/actions/[email protected] | ||
|
||
- name: Install asdf plugins & packages | ||
run: | | ||
asdf plugin add earthly https://github.com/YR-ZR0/asdf-earthly | ||
asdf plugin update --all | ||
asdf install | ||
- name: Put back the git branch into git (Earthly uses it for tagging) | ||
run: | | ||
branch="" | ||
if [ -n "$GITHUB_HEAD_REF" ]; then | ||
branch="$GITHUB_HEAD_REF" | ||
else | ||
branch="${GITHUB_REF##*/}" | ||
fi | ||
git checkout -b "$branch" || true | ||
- name: Earthly version | ||
run: earthly --version | ||
|
||
- name: Run build | ||
run: make ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
earthly 0.7.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
VERSION 0.7 | ||
FROM earthly/dind:alpine-3.18-docker-23.0.6-r4 | ||
WORKDIR /app | ||
|
||
deps: | ||
FROM DOCKERFILE --target "base" . | ||
|
||
dev: | ||
FROM DOCKERFILE --target "dev" . | ||
|
||
prod: | ||
FROM DOCKERFILE --target "prod" . | ||
|
||
lint: | ||
FROM +dev | ||
RUN bash scripts/lint.sh | ||
|
||
format: | ||
FROM +dev | ||
RUN bash scripts/format.sh | ||
|
||
# FIXME: we don't mount .git files in containers, so this doesn't work | ||
# pre-commit: | ||
# FROM +dev | ||
# RUN bash scripts/pre-commit.sh | ||
|
||
unit-tests: | ||
FROM +dev | ||
RUN bash scripts/unit-tests.sh | ||
|
||
coverage: | ||
FROM +dev | ||
RUN bash scripts/coverage.sh | ||
|
||
functional-tests: | ||
FROM +dev | ||
COPY docker-compose.yaml . | ||
WITH DOCKER \ | ||
--compose docker-compose.yaml \ | ||
--load webofmars/cicdparadox:earthly-latest=+prod \ | ||
--load webofmars/cicdparadox:earthly-develop=+dev \ | ||
--service mongo --service api | ||
RUN bash scripts/functional-tests.sh | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
all: build ci publish | ||
|
||
build: docker-build | ||
ci: lint format unit-tests coverage functional-tests ci-clean | ||
ci: lint format unit-tests coverage functional-tests | ||
publish: docker-publish | ||
|
||
lint: | ||
bash scripts/lint.sh | ||
earthly +lint | ||
|
||
format: | ||
bash scripts/format.sh | ||
earthly +format | ||
|
||
pre-commit: | ||
bash scripts/pre-commit.sh | ||
# FIXME: since we don't mount .git folders in docker, we can't use pre-commit | ||
# pre-commit: | ||
# earthly +pre-commit | ||
|
||
unit-tests: | ||
bash scripts/unit-tests.sh | ||
earthly +unit-tests | ||
|
||
coverage: | ||
bash scripts/coverage.sh | ||
earthly +coverage | ||
|
||
functional-tests: | ||
bash scripts/functional-tests.sh | ||
earthly --allow-privileged +functional-tests | ||
|
||
ci-clean: | ||
rm -rf .pytest_cache | ||
rm -rf .mypy_cache | ||
earthly prune | ||
|
||
docker-build: docker-build-prod docker-build-dev | ||
|
||
docker-build-prod: | ||
docker build -t webofmars/cicdparadox:standard-latest --target=prod . | ||
earthly +prod | ||
|
||
docker-build-dev: | ||
docker build -t webofmars/cicdparadox:standard-develop --target=dev . | ||
earthly +dev | ||
|
||
docker-publish: docker-build | ||
docker push webofmars/cicdparadox:standard-latest | ||
earthly prod --push | ||
earthly dev --push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters