Skip to content

Commit

Permalink
ci(build): parallel jobs and cache for faster build (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Mar 16, 2023
1 parent 74a3d15 commit 0f84af0
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 12 deletions.
124 changes: 118 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,137 @@ on:
- 'main'
- 'develop'
jobs:
build:
install:
runs-on: ubuntu-latest
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Start Docker containers 🐳
run: npm run docker:test:start
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Install project dependencies 📦
run: npm ci --ignore-scripts
if: steps.cache-node-modules.outputs.cache-hit != 'true'
build:
runs-on: ubuntu-latest
needs:
- install
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Build app ✨
run: npm run build
lint:
runs-on: ubuntu-latest
needs:
- install
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Check and lint code 🔍
run: npm run lint
- name: Test 💯
run: npm run test:cov
unit-tests:
runs-on: ubuntu-latest
needs:
- install
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Start Docker containers 🐳
run: npm run docker:test:start
- name: Unit tests 💯
run: npm run test:unit:cov -- --verbose=false
- name: Stop Docker containers 🐳
if: ${{ always() }}
run: npm run docker:test:stop
e2e-tests:
runs-on: ubuntu-latest
needs:
- install
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Start Docker containers 🐳
run: npm run docker:test:start
- name: E2E tests 💯
run: npm run test:e2e:cov -- --verbose=false
- name: Stop Docker containers 🐳
if: ${{ always() }}
run: npm run docker:test:stop
mutant-tests:
runs-on: ubuntu-latest
needs:
- install
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Start Docker containers 🐳
run: npm run docker:test:start
- name: Mutant tests 👽
run: npm run test:stryker
- name: Stop Docker containers 🐳
if: ${{ always() }}
run: npm run docker:test:stop
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ jobs:
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install project dependencies 📦
run: npm ci --ignore-scripts
node-version-file: '.nvmrc'
cache: 'npm'
- name: Cache npm dependencies 🥡
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }}
- name: Release 🏷️
run: npx semantic-release
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
9 changes: 8 additions & 1 deletion tests/e2e/specs/game/game.module.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ describe("Game Module", () => {
errorMessage: "players.name must be unique",
},
{
payload: createFakeCreateGameDto({ players: bulkCreateFakeCreateGamePlayerDto(4, [{ role: { name: ROLE_NAMES.THREE_BROTHERS } }]) }),
payload: createFakeCreateGameDto({
players: bulkCreateFakeCreateGamePlayerDto(4, [
{ role: { name: ROLE_NAMES.THREE_BROTHERS } },
{ role: { name: ROLE_NAMES.VILLAGER_VILLAGER } },
{ role: { name: ROLE_NAMES.WEREWOLF } },
{ role: { name: ROLE_NAMES.SEER } },
]),
}),
test: "there is only one brother in the same game",
errorMessage: "players.role minimum occurrences in game must be reached. Please check `minInGame` property of roles",
},
Expand Down

0 comments on commit 0f84af0

Please sign in to comment.