Skip to content

Instantly share code, notes, and snippets.

@lydemann
Last active Sep 20, 2022
Embed
What would you like to do?
# ci.yml
name: CI
env:
# Branching
is-merge: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
is-pull-request: ${{ github.event_name == 'pull_request' }}
NODE_OPTIONS: --max-old-space-size=6144
on:
push:
branches:
- main
pull_request: {}
jobs:
builds:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
# Required by nrwl/nx-set-shas
fetch-depth: 0
- name:
'Derive appropriate SHAs for base and head for `nx affected` commands'
uses: nrwl/nx-set-shas@v2
- name: Set up dependencies
uses: ./.github/actions/setup-dependencies
- name: 'PR: Build application if affected by changes in feature branch'
if: env.is-pull-request == 'true'
run: yarn affected:build
- name: 'Merge: Build application'
if: env.is-merge == 'true'
run: yarn build
name: CI
env:
# Branching
is-merge: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
is-pull-request: ${{ github.event_name == 'pull_request' }}
# Node.js
NODE_OPTIONS: --max-old-space-size=6144
on:
push:
branches:
- main
pull_request: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
# Required by nrwl/nx-set-shas
fetch-depth: 0
- name:
'Derive appropriate SHAs for base and head for `nx affected` commands'
uses: nrwl/nx-set-shas@v2
- name: Set up dependencies
uses: ./.github/actions/setup-dependencies
- name: 'Build application if affected by changes in feature branch'
run: yarn affected:build
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
# Required by nrwl/nx-set-shas
fetch-depth: 0
- name:
'Derive appropriate SHAs for base and head for `nx affected` commands'
uses: nrwl/nx-set-shas@v2
- name: Set up dependencies
uses: ./.github/actions/setup-dependencies
- name: Lint Nx workspace
run: yarn nx workspace-lint
- name: 'Lint workspace and affected projects'
run: yarn affected:lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
# Required by nrwl/nx-set-shas
fetch-depth: 0
- name:
'Derive appropriate SHAs for base and head for `nx affected` commands'
uses: nrwl/nx-set-shas@v2
- name: Set up dependencies
uses: ./.github/actions/setup-dependencies
- name: 'Test affected projects'
run: yarn test
e2e:
name: End-to-end test
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
# Required by nrwl/nx-set-shas
fetch-depth: 0
- name:
'Derive appropriate SHAs for base and head for `nx affected` commands'
uses: nrwl/nx-set-shas@v2
- name: Set up dependencies
uses: ./.github/actions/setup-dependencies
- name:
'End-to-end test application if affected by changes in feature
branch'
run: yarn affected:e2e --configuration=ci-production
name: CI
env:
NODE_OPTIONS: --max-old-space-size=6144
on:
push:
branches:
- main
pull_request: {}
jobs:
builds:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run build
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run lint
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run e2e
"scripts": {
"ng": "nx",
"start": "nx serve",
"build": "nx run-many --target=build --all --parallel",
"test": "nx run-many --target=test --all --parallel",
"lint": "nx run-many --target=lint --all --parallel",
"e2e": "nx run-many --target=e2e --all"
}
"scripts": {
"affected:build": "nx affected:build --configuration=production",
"affected:ci": "yarn affected:build && yarn affected:lint && yarn affected:test && yarn affected:e2e --configuration=ci-production",
"affected:e2e": "nx affected:e2e",
"affected:lint": "nx affected:lint --max-warnings=0",
"affected:test": "nx affected:test",
}
name: CI
env:
NODE_OPTIONS: --max-old-space-size=6144
on:
push:
branches:
- main
pull_request: {}
jobs:
builds:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run build
- run: npm run test
- run: npm run lint
- run: npm run e2e
@lydemann
Copy link
Author

lydemann commented Sep 20, 2022

Thanks @LayZeeDK ! Updated it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment