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

Build : improve CI #3334

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
31 changes: 10 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
name: Intégration continue

on:
push:
branches:
- main
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
# release:
# types: [published]

env:
REGISTRY_USER: ${{ secrets.GH_USER }}
REGISTRY_TOKEN: ${{ secrets.GH_TOKEN }}

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

jobs:
#test-unit:

build-tools:
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: earthly/actions-setup@v1
with:
version: 0.8.1

github-token: ${{ secrets.GITHUB_TOKEN }}
version: ^0.8.0
- name: Login into registry
run: earthly --use-inline-cache +docker-dev-login --GH_USER=${{ secrets.GH_USER }} --GH_TOKEN=${{ secrets.GH_TOKEN }}
run: echo "${{ secrets.GH_TOKEN }} qwqw ${{ secrets.GH_USER }}" | earthly --use-inline-cache +docker-dev-login --GH_USER=${{ secrets.GITHUB_USER }} --GH_TOKEN=${{ secrets.GITHUB_TOKEN }}

- name: Build and push Sqitch
run: earthly --use-inline-cache --save-inline-cache --push +sqitch-builder
Expand All @@ -39,8 +41,6 @@ jobs:
run: earthly --use-inline-cache --save-inline-cache --push +pg-tap-builder

build-business-dev:
# todo: needs: unit-test
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -60,7 +60,6 @@ jobs:
run: earthly --use-inline-cache --save-inline-cache --push +business-build

prepare-front-deps:
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -81,7 +80,6 @@ jobs:

build-app-dev:
needs: prepare-front-deps
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -102,7 +100,6 @@ jobs:

build-auth-dev:
needs: prepare-front-deps
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand All @@ -122,7 +119,6 @@ jobs:
run: earthly --use-inline-cache --save-inline-cache --push +auth-build --ANON_KEY=${{ secrets.ANON_KEY }} --API_URL=${{ secrets.API_URL }}

build-db:
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -155,7 +151,6 @@ jobs:
- build-business-dev
- build-tools
- build-db
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -208,7 +203,6 @@ jobs:
- build-tools
- build-db
- prepare-front-deps
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -275,7 +269,6 @@ jobs:
- build-business-dev
- build-tools
- build-db
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -324,7 +317,6 @@ jobs:

test-app:
needs: prepare-front-deps
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -352,7 +344,6 @@ jobs:
- build-business-dev
- build-tools
- build-db
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -398,7 +389,6 @@ jobs:
- build-business-dev
- build-tools
- build-db
environment: dev
runs-on: ubuntu-latest
timeout-minutes: 30

Expand Down Expand Up @@ -438,7 +428,6 @@ jobs:
- build-app-dev
- build-auth-dev
- build-db
environment: dev
name: End-to-end tests
runs-on: ubuntu-latest
timeout-minutes: 60
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/shared-build-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Shared build setup

on: workflow_call

jobs:
shared-build-setup:
runs-on: ubuntu-latest
environment: dev

steps:
- uses: actions/checkout@v4

- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GH_TOKEN }}
version: ^0.8.0

- name: Login into Docker registry
run: docker login ghcr.io/territoiresentransitions --username "${{ secrets.GH_USER }}" --password "${{ secrets.GH_TOKEN }}"
16 changes: 8 additions & 8 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ ARG --global API_DIR='./packages/api'
ARG --global BUSINESS_DIR='./business'
# paramètres de la base de registre des images docker générées
ARG --global REGISTRY='ghcr.io'
ARG --global REG_USER='territoiresentransitions'
ARG --global REG_USER='incubateur-ademe'
ARG --global REG_TARGET=$REGISTRY/$REG_USER
# tags appliqués aux images docker générées
ARG --global ENV_NAME="dev"
ARG --global FRONT_DEPS_TAG=$(openssl dgst -sha256 -r ./pnpm-lock.yaml | head -c 7 ; echo)
ARG --global FRONT_DEPS_IMG_NAME=$REG_TARGET/front-deps:$FRONT_DEPS_TAG
ARG --global FRONT_DEPS_IMG_NAME=$REG_TARGET/tet-front-deps:$FRONT_DEPS_TAG
ARG --global APP_TAG=$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $APP_DIR,$UI_DIR,$API_DIR)
ARG --global APP_IMG_NAME=$REG_TARGET/app:$APP_TAG

Expand All @@ -26,15 +26,15 @@ ARG --global APP_IMG_NAME=$REG_TARGET/app:$APP_TAG
ARG --global APPLICATION_VERSION=$(git describe --tags --always)

# TODO changer le tag
ARG --global BACKEND_IMG_NAME=$REG_TARGET/backend:$ENV_NAME-$EARTHLY_GIT_SHORT_HASH
ARG --global SITE_IMG_NAME=$REG_TARGET/site:$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $SITE_DIR,$UI_DIR,$API_DIR)
ARG --global AUTH_IMG_NAME=$REG_TARGET/auth:$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $AUTH_DIR,$UI_DIR,$API_DIR)
ARG --global BACKEND_IMG_NAME=$REG_TARGET/tet-backend:$ENV_NAME-$EARTHLY_GIT_SHORT_HASH
ARG --global SITE_IMG_NAME=$REG_TARGET/tet-site:$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $SITE_DIR,$UI_DIR,$API_DIR)
ARG --global AUTH_IMG_NAME=$REG_TARGET/tet-auth:$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $AUTH_DIR,$UI_DIR,$API_DIR)
ARG --global PANIER_IMG_NAME=$REG_TARGET/panier:$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $PANIER_DIR,$UI_DIR,$API_DIR)
ARG --global STORYBOOK_TAG=$ENV_NAME-$FRONT_DEPS_TAG-$(sh ./subdirs_hash.sh $UI_DIR)
ARG --global STORYBOOK_IMG_NAME=$REG_TARGET/storybook:$STORYBOOK_TAG
ARG --global BUSINESS_IMG_NAME=$REG_TARGET/business:$ENV_NAME-$(sh ./subdirs_hash.sh $BUSINESS_DIR)
ARG --global STORYBOOK_IMG_NAME=$REG_TARGET/tet-storybook:$STORYBOOK_TAG
ARG --global BUSINESS_IMG_NAME=$REG_TARGET/tet-business:$ENV_NAME-$(sh ./subdirs_hash.sh $BUSINESS_DIR)
ARG --global DL_TAG=$ENV_NAME-$(sh ./subdirs_hash.sh data_layer)
ARG --global DB_SAVE_IMG_NAME=$REG_TARGET/db-save:$DL_TAG
ARG --global DB_SAVE_IMG_NAME=$REG_TARGET/tet-db-save:$DL_TAG
ARG --global DB_VOLUME_NAME=supabase_db_tet
ARG --global GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

Expand Down
3 changes: 2 additions & 1 deletion packages/site/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ docker:
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "packages/site/server.js"]

SAVE IMAGE --push $DOCKER_IMAGE
SAVE IMAGE --cache-from $CI_REGISTRY_IMAGE:latest --push $DOCKER_IMAGE my-image:$ENV_NAME-latest
# FROM DOCKERFILE

deploy:
ARG --required KOYEB_API_KEY
Expand Down