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

chore: CI/CD refactoring #598

Merged
merged 38 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8a188e5
removed codecov as it's more trouble then good
ZibanPirate Sep 14, 2024
a5184a1
reusable build workflow
ZibanPirate Sep 14, 2024
f81459a
switch quotes
ZibanPirate Sep 14, 2024
99345fd
toJSON
ZibanPirate Sep 14, 2024
c4c42e4
no matrix
ZibanPirate Sep 14, 2024
1ee2064
correct inputs
ZibanPirate Sep 14, 2024
a066187
separated install and build jobs
ZibanPirate Sep 14, 2024
9ddbc31
upload dist artifacts
ZibanPirate Sep 14, 2024
0df14fa
include node_modules
ZibanPirate Sep 14, 2024
8d22ed4
include node_modules
ZibanPirate Sep 14, 2024
32bac16
fixed paths
ZibanPirate Sep 14, 2024
c1be132
reusable test-coverage workflow
ZibanPirate Sep 14, 2024
3b0b14f
try installing again
ZibanPirate Sep 14, 2024
ae14651
don't cache node_modules
ZibanPirate Sep 14, 2024
b008468
reusable lint workflow
ZibanPirate Sep 14, 2024
102c07c
reusable misc workflow
ZibanPirate Sep 14, 2024
956f75a
reusable test-e2e workflow
ZibanPirate Sep 14, 2024
c5df6cf
added labler job
ZibanPirate Sep 14, 2024
b76f493
checkout before lebeling
ZibanPirate Sep 14, 2024
71d8f8b
removed unused jest config
ZibanPirate Sep 14, 2024
18591c3
Remove lerna-debug.log from .gitignore
ZibanPirate Sep 14, 2024
c607b1f
Add labeler configuration for changed files in .github directory
ZibanPirate Sep 14, 2024
8e84f1a
moved use reusable configuration files into a folder
ZibanPirate Sep 14, 2024
f3aba19
use reusable jobs in main ci
ZibanPirate Sep 14, 2024
9e4e176
reuse workflows in deploy workflow
ZibanPirate Sep 14, 2024
07370d3
moved workflows to root of wf dir
ZibanPirate Sep 14, 2024
275b924
Refactor deployment workflow to include dependency on build job
ZibanPirate Sep 14, 2024
2a6bb71
reuse workflows in prod deploy workflow
ZibanPirate Sep 14, 2024
3d423e9
removed debug trigger
ZibanPirate Sep 14, 2024
7ade870
upgraded CodeQL
ZibanPirate Sep 15, 2024
540a8f8
removed JS cuz it's part of TS codeql
ZibanPirate Sep 15, 2024
b8a9431
add os matrix for all jobs
ZibanPirate Sep 15, 2024
744551d
make artifact uniq per matrix
ZibanPirate Sep 15, 2024
dbc9b4f
restricted upload files
ZibanPirate Sep 15, 2024
839e0be
only test on chrome
ZibanPirate Sep 15, 2024
7a0baf8
escape @ for windows shells
ZibanPirate Sep 15, 2024
eced1a9
short reusable job names
ZibanPirate Sep 15, 2024
21dd123
updated main branch with matrix
ZibanPirate Sep 15, 2024
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
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
Loading