Skip to content

Commit

Permalink
Merge pull request #598 from dzcode-io/ci-fixes
Browse files Browse the repository at this point in the history
chore: CI/CD refactoring
  • Loading branch information
ZibanPirate authored Sep 17, 2024
2 parents 6248d5f + 21dd123 commit 2df56c4
Show file tree
Hide file tree
Showing 16 changed files with 368 additions and 361 deletions.
54 changes: 19 additions & 35 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,31 @@
# Add 'api' to any changes within 'api' folder or any subfolders
web:
- changed-files:
- any-glob-to-any-file: web/**/*

api:
- api/**/*
- changed-files:
- any-glob-to-any-file: api/**/*

# Add 'data' to any changes within 'data' folder or any subfolders
data:
- data/**/*
- changed-files:
- any-glob-to-any-file: data/**/*

# Add 'project' to any changes within 'data/models/projects' folder or any subfolders
project:
- data/models/projects/**/*

# Add 'article' to any changes within 'data/models/articles' folder or any subfolders
article:
- data/models/articles/**/*

# Add 'documentation' to any changes within 'data/models/documentation' folder or any subfolders
documentation:
- data/models/documentation/**/*
- changed-files:
- any-glob-to-any-file: data/models/projects/**/*

# Add 'web' to any changes within 'web' folder or any subfolders
web:
- web/**/*

# Add 'mobile' to any changes within 'mobile' folder or any subfolders
mobile:
- mobile/**/*

# Add 'models' to any changes within 'models' folder or any subfolders
models:
- packages/models/**/*
- changed-files:
- any-glob-to-any-file: packages/models/**/*

# Add 'utils' to any changes within 'utils' folder or any subfolders
utils:
- packages/utils/**/*
- changed-files:
- any-glob-to-any-file: packages/utils/**/*

# Add 'tooling' to any changes within 'tooling' folder or any subfolders
tooling:
- packages/tooling/**/*

# Add 'ui' to any changes within 'ui' folder or any subfolders
ui:
- packages/ui/**/*
- changed-files:
- any-glob-to-any-file: packages/tooling/**/*

# Add 'ui-mobile' to any changes within 'ui-mobile' folder or any subfolders
ui-mobile:
- packages/ui-mobile/**/*
repo:
- changed-files:
- any-glob-to-any-file: .github/**/*
62 changes: 24 additions & 38 deletions .github/workflows/cd.deploy.stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ on:
workflow_dispatch:

jobs:
install-build-deploy:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [20.x]
os: [ubuntu-latest]

build:
uses: ./.github/workflows/ci.reusable.build.yml
with:
node-version: "20"
os: "ubuntu-latest"

bundle-deploy:
needs: build
runs-on: ubuntu-latest
env:
CI: true
STAGE: staging
Expand All @@ -25,42 +26,27 @@ jobs:

steps:
- name: "Git"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Nodejs"
uses: actions/setup-node@v4
with:
fetch-depth: 0
node-version: "20"
cache: "npm"
- run: npm ci
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build output (ubuntu-latest, 20)
- name: "SSH"
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: "Nodejs"
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: "Install"
shell: bash
run: |
npm ci
- name: "Bundle info"
shell: bash
run: |
npm run generate:bundle-info $DEPLOY_VERSION stage
- name: "Build"
shell: bash
run: |
npm run build
npx lerna run bundle:alone --scope @dzcode.io/web
run: npm run generate:bundle-info $DEPLOY_VERSION stage
- name: "Bundle ./web"
run: npx lerna run bundle:alone --scope @dzcode.io/web
- name: "Sentry Release"
shell: bash
run: |
npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
run: npm run generate:sentry-release $DEPLOY_VERSION stage ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: "Deploy"
shell: bash
run: |
npm run deploy:stg
run: npm run deploy:stg
69 changes: 24 additions & 45 deletions .github/workflows/cd.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ on:
- "v*"

jobs:
install-build-deploy:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [20.x]
os: [ubuntu-latest]

build:
uses: ./.github/workflows/ci.reusable.build.yml
with:
node-version: "20"
os: "ubuntu-latest"

bundle-deploy:
needs: build
runs-on: ubuntu-latest
env:
CI: true
STAGE: production
Expand All @@ -24,49 +25,27 @@ jobs:

steps:
- name: "Git"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Nodejs"
uses: actions/setup-node@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_ZAK_PAT }}
node-version: "20"
cache: "npm"
- run: npm ci
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build output (ubuntu-latest, 20)
- name: "SSH"
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: "Nodejs"
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: "Install"
shell: bash
run: |
npm ci
- name: "Version"
shell: bash
run: |
npm run version:apply $DEPLOY_VERSION
npm run version:push $DEPLOY_VERSION
- name: "Bundle info"
shell: bash
run: |
npm run generate:bundle-info $DEPLOY_VERSION production
- name: "Build"
shell: bash
run: |
npm run build
npx lerna run bundle:alone --scope @dzcode.io/web
run: npm run generate:bundle-info $DEPLOY_VERSION production
- name: "Bundle ./web"
run: npx lerna run bundle:alone --scope @dzcode.io/web
- name: "Sentry Release"
shell: bash
run: |
npm run generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
run: npm run generate:sentry-release $DEPLOY_VERSION production ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: "Deploy"
shell: bash
run: |
npm run deploy
run: npm run deploy
133 changes: 50 additions & 83 deletions .github/workflows/ci.main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,59 @@ on:
- main

jobs:
install-build-lint-test-coverage-misc:
runs-on: ${{ matrix.os }}

build:
uses: ./.github/workflows/ci.reusable.build.yml
strategy:
matrix:
node-version: [20.x]
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false

steps:
- name: "Git"
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Nodejs"
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: "Install"
shell: bash
run: |
npm ci
- name: "Build"
shell: bash
run: |
npm run build
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
node-version: ["20"]
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}

- name: "Lint"
shell: bash
run: |
npm run lint:alone
- name: "Test"
shell: bash
run: |
npm run test:alone -- -- --coverage
test-coverage:
needs: build
uses: ./.github/workflows/ci.reusable.test-coverage.yml
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
node-version: ["20"]
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}

- uses: codecov/codecov-action@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: api
name: codecov-api
directory: ./api
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: web
name: codecov-web
directory: ./web
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: data
name: codecov-data
directory: ./data
fail_ci_if_error: false # put it back to true once we have tests in ./data
- uses: codecov/codecov-action@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: models
name: codecov-models
directory: ./packages/models
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
flags: utils
name: codecov-utils
directory: ./packages/utils
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
lint:
needs: build
uses: ./.github/workflows/ci.reusable.lint.yml
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
node-version: ["20"]
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}

- name: "Misc"
shell: bash
run: |
npx lerna run bundle:alone --scope @dzcode.io/web
npx lerna run generate:sitemap --scope @dzcode.io/web
npx lerna run generate:htmls --scope @dzcode.io/web
misc:
needs: build
uses: ./.github/workflows/ci.reusable.misc.yml
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
node-version: ["20"]
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}

env:
CI: true
test-e2e:
needs: build
uses: ./.github/workflows/ci.reusable.test-e2e.yml
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
node-version: ["20"]
# @TODO-ZM: add other browsers once we replace cypress with playwright
browser: ["chrome"]
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
browser: ${{ matrix.browser }}
Loading

0 comments on commit 2df56c4

Please sign in to comment.