Skip to content

Commit

Permalink
ci: test out new nx workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed May 1, 2022
1 parent 786cca0 commit 67a19c0
Show file tree
Hide file tree
Showing 28 changed files with 470 additions and 183 deletions.
47 changes: 0 additions & 47 deletions .github/actions/run-tests/action.yml

This file was deleted.

143 changes: 53 additions & 90 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,43 @@ on:
- cron: '0 0 * * *'

env:
NX_BRANCH: ${{ github.event.pull_request.head.ref }}
NX_RUN_GROUP: ${{ github.run_id }}
NX_VERBOSE_LOGGING: true
NX_CLOUD_DISTRIBUTED_EXECUTION: ${{ !contains(github.event.pull_request.user.login, 'dependabot') && !contains(github.event.pull_request.user.login, 'renovate') }}
NX_CLOUD_AUTH_TOKEN: ${{ startsWith(github.repository, 'jmcdo29') && secrets.NX_CLOUD_TOKEN || 'ODFlNDgyYzItZTgwYy00OTQyLTkxNTgtOWQ4ZTVlNDU3OTU2fHJlYWQ=' }}
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_TOKEN }}

jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/[email protected]
with:
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx workspace-lint
pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3
pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
pnpm exec nx affected --target=build --parallel=3
pnpm exec nx affected --target=e2e
report-coverage:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v3
name: Checkout [main]
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
- name: Use Node.js 14
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Run Build and Tests
uses: ./.github/actions/run-tests

pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
- name: Use Node.js 14
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Run Build and Tests
uses: ./.github/actions/run-tests
node-version: 16.x
- name: Install pnpm
run: npm i -g pnpm
- name: Install deps
run: pnpm i
- name: Collect Test Coverage
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false pnpm nx run tools:collect
- name: Send Test Coverage:with
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage/lcov.info
shell: bash
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}

analyze:
name: Analyze
Expand All @@ -63,66 +59,33 @@ jobs:
language: ['javascript']

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

auto-merge:
needs: pr
if: contains(github.event.pull_request.user.login, 'dependabot') || contains(github.event.pull_request.user.login, 'renovate')
needs: main
if: contains(github.event.pull_request.user.login, 'dependabot') || contains(github.event.pull_request.user.login, 'renovate') && ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: automerge
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: ""
MERGE_METHOD: rebase

send-coverage:
runs-on: ubuntu-latest
needs: [pr, main]
if: always()
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Download Coverage
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage/

- name: Send Coverage
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage/lcov.info
shell: bash
- name: automerge
uses: pascalgn/[email protected]
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
MERGE_LABELS: ''
MERGE_METHOD: rebase

agents:
runs-on: ubuntu-latest
name: Agent 1
timeout-minutes: 60
strategy:
matrix:
agent: [ 1, 2, 3 ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Install pnpm
run: npm i -g pnpm
- name: Install deps
run: pnpm i --frozen-lockfile=false
- name: Start Nx Agent ${{ matrix.agent }}
run: pnpm nx-cloud start-agent
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/[email protected]
with:
number-of-agents: 3
20 changes: 5 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,8 @@ jobs:
- name: Stop Nx Cloud Agents
run: pnpx -y nx-cloud stop-all-agents

agent_1:
runs-on: ubuntu-latest
name: Agent 1
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Install pnpm
run: npm i -g pnpm

- name: Install Dependencies
run: pnpm i --frozen-lockfile=false
- run: pnpx -y nx-cloud start-agent
agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/[email protected]
with:
number-of-agents: 1
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion integration/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"reporter": [
"text",
"json"
"lcov"
],
"reportDir": "integration/coverage"
}
14 changes: 12 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": ["build", "test", "lint", "package", "prepare"],
"cacheableOperations": [
"build",
"test",
"lint",
"package",
"prepare",
"e2e",
"e2e-run",
"docker-up",
"docker-ready"
],
"strictlyOrderedTargets": ["build", "package", "prepare"],
"canTrackAnalytics": false,
"showUsageWarnings": true,
"parallel": 1
"accessToken": "ODFlNDgyYzItZTgwYy00OTQyLTkxNTgtOWQ4ZTVlNDU3OTU2fHJlYWQ="
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"hanbi": "^1.0.1",
"husky": "^7.0.2",
"kafkajs": "^1.15.0",
"lcov-result-merger": "^3.1.0",
"lint-staged": "12.4.1",
"module-alias": "^2.2.2",
"morgan": "^1.10.0",
Expand Down Expand Up @@ -142,6 +143,5 @@
"resolutions": {
"apollo-cache-control": "0.14.0",
"axios": "~0.27.0"
},
"dependencies": {}
}
}
2 changes: 1 addition & 1 deletion packages/cli/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/cli/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/cli/coverage"
}
2 changes: 1 addition & 1 deletion packages/logger/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/logger/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/logger/coverage"
}
2 changes: 1 addition & 1 deletion packages/nestjs-module/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/nestjs-module/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/nestjs-module/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-express/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-express/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-express/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-fastify/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-fastify/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-fastify/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-graphql-fastify/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-graphql-fastify/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-graphql-fastify/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-graphql/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-graphql/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-graphql/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-grpc/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-grpc/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-grpc/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-kafka/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-kafka/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-kafka/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-mqtt/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-mqtt/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-mqtt/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-nats/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-nats/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-nats/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-rabbitmq/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-rabbitmq/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-rabbitmq/coverage"
}
2 changes: 1 addition & 1 deletion packages/platform-redis/.c8rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"include": [
"packages/platform-redis/src/**/*.ts"
],
"reporter": ["text", "json"],
"reporter": ["text", "lcov"],
"reportDir": "./packages/platform-redis/coverage"
}
Loading

0 comments on commit 67a19c0

Please sign in to comment.