From 5f687a4ac376c38c3d6363a48a4e17d98d36deef Mon Sep 17 00:00:00 2001 From: mateonunez Date: Wed, 1 Nov 2023 20:24:34 +0100 Subject: [PATCH 1/2] refactor(ci): composite the action Signed-off-by: mateonunez --- .github/workflows/ci.yml | 87 +++++----------------------------------- 1 file changed, 9 insertions(+), 78 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ac731d4..9a363189 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,105 +12,36 @@ jobs: setup-dependencies: runs-on: ${{matrix.os}} strategy: + fail-fast: false matrix: os: [ubuntu-latest] - node-version: [16, 18, 20] + node: [18, 20] steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2.4.0 - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: ${{matrix.node}} cache: 'pnpm' - run: pnpm fetch - ci-cli: + package-tests: needs: setup-dependencies runs-on: ${{matrix.os}} strategy: + fail-fast: false matrix: os: [ubuntu-latest] - node-version: [16, 18] + node: [18, 20] + package: [cli, drill, falcon, huston, rover] steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2.4.0 - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: ${{matrix.node}} cache: 'pnpm' - run: pnpm install - - run: cd packages/cli && pnpm test - - ci-drill: - needs: setup-dependencies - runs-on: ${{matrix.os}} - timeout-minutes: 20 - strategy: - matrix: - os: [ubuntu-latest] - node-version: [16, 18] - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2.4.0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: 'pnpm' - - run: docker-compose up -d - - run: pnpm install - - run: sleep 10 - - run: cd packages/drill && pnpm test - - ci-falcon: - needs: setup-dependencies - runs-on: ${{matrix.os}} - timeout-minutes: 20 - strategy: - matrix: - os: [ubuntu-latest] - node-version: [16, 18] - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2.4.0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: 'pnpm' - run: docker-compose up -d - - run: pnpm install - run: sleep 10 - - run: cd packages/falcon && pnpm test - - ci-huston: - needs: setup-dependencies - runs-on: ${{matrix.os}} - strategy: - matrix: - os: [ubuntu-latest] - node-version: [16, 18] - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2.4.0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: 'pnpm' - - run: pnpm install - - run: cd packages/huston && pnpm test - - ci-rover: - needs: setup-dependencies - runs-on: ${{matrix.os}} - strategy: - matrix: - os: [ubuntu-latest] - node-version: [16, 18] - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2.4.0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: 'pnpm' - - run: pnpm install - - run: cd packages/rover && pnpm test + - run: cd packages/${{matrix.package}} && pnpm test From cc5553f6d9d29fd91b6eec72f2f1268e2160eace Mon Sep 17 00:00:00 2001 From: mateonunez Date: Wed, 1 Nov 2023 20:29:40 +0100 Subject: [PATCH 2/2] perf(ci): implement healthcheck Signed-off-by: mateonunez --- .github/workflows/ci.yml | 7 ++++++- docker-compose.yml | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a363189..48fd3702 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,5 +43,10 @@ jobs: cache: 'pnpm' - run: pnpm install - run: docker-compose up -d - - run: sleep 10 + - name: Wait for databases to be healthy + run: | + while [ "$(docker-compose ps mysql | grep '(healthy)')" == "" ] || [ "$(docker-compose ps postgres | grep '(healthy)')" == "" ]; do + echo "Waiting for databases to be healthy..." + sleep 5 + done - run: cd packages/${{matrix.package}} && pnpm test diff --git a/docker-compose.yml b/docker-compose.yml index 3f4cc0e5..45e5a208 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,11 @@ services: MYSQL_ROOT_PASSWORD: toor networks: - asterism_network + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "--password=toor"] + interval: 10s + timeout: 5s + retries: 5 postgres: image: postgres:15-alpine @@ -22,6 +27,11 @@ services: POSTGRES_PASSWORD: toor networks: - asterism_network + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres", "-d", "db"] + interval: 10s + timeout: 5s + retries: 5 networks: asterism_network: