Replies: 4 comments 21 replies
-
One solution would be to consolidate all CI code into a single action, such as continuous-integration.ymlname: Continuous integration
on: # TODO: determine best "on" configuration
push:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
pull_request:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
env:
CI: true # is this needed?
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true # is this needed?
jobs:
setup:
name: Setup
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "12.16.1"
- id: cache-node-modules
name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm # npm caches files in ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm install --no-audit
lint:
name: Lint
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
needs: setup
steps: # will it work to only have the lint step here?
- name: Run lint
run: npm run lint
unit:
name: Unit tests
defaults:
run:
working-directory: "packages/vocabulary"
runs-on: ubuntu-latest
needs: setup
steps: # Will it work to only have the "run tests" step here?
- name: Run tests
run: npm run test:unit
build:
name: Build
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
needs: setup
steps: # Will it work to only have the "run build" step here?
- name: Run build
run: npm run build:storybook |
Beta Was this translation helpful? Give feedback.
-
I totally agree, the three scripts I think run the same commands so it will make sense resource-wise to use one file as you suggested. For local testing of github actions I am using a package: |
Beta Was this translation helpful? Give feedback.
-
Alternatively, we can separate the continuous integration scripts along the lines of their purpose, such as
In the above division, we would end up with three files, each demonstrated in a relevant section below. ci-lint.ymlname: Lint
on: # TODO: determine best "on" configuration
push:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
pull_request:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
env:
CI: true # Is this needed?
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true # Is this needed?
jobs:
setup:
name: Setup
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "12.16.1"
- id: cache-node-modules
name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm # npm caches files in ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm install --no-audit
lint:
name: Lint
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
needs: setup
steps: # Will this work as expected with only the "run lint" step?
- name: Run lint
run: npm run lint ci-test.ymlname: Unit test
on: # TODO: determine best "on" configuration
push:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
pull_request:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
env:
CI: true # Is this needed?
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true # Is this needed?
jobs:
setup:
name: Setup
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "12.16.1"
- id: cache-node-modules
name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm # npm caches files in ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm install --no-audit
unit:
name: Unit tests
defaults:
run:
working-directory: "packages/fonts"
runs-on: ubuntu-latest
needs: setup
steps: # Will this work with only the "run tests" step?
- name: Run tests
run: npm run test:unit ci-build.ymlname: Build
on: # TODO: determine best "on" configuration
push:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
pull_request:
paths:
- "packages/**"
- "scripts/**"
- "src/**"
branches:
- main
env:
CI: true # Is this needed?
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true # Is this needed?
jobs:
setup:
name: Setup
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "12.16.1"
- id: cache-node-modules
name: Cache Node.js modules
uses: actions/cache@v1
with:
path: ~/.npm # npm caches files in ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm install --no-audit
build:
name: Build
defaults:
run:
working-directory: "/"
runs-on: ubuntu-latest
needs: setup
steps: # Will this work with only the "run build" step defined?
- name: Run build
run: npm run build:storybook |
Beta Was this translation helpful? Give feedback.
-
I think I may be able to further optimize the CI scripts to further reduce over-using resources which may also be able to close #973 |
Beta Was this translation helpful? Give feedback.
-
For context, we have recently refactored this project so there is only a single
src/
directory containing all package code.We currently have three CI actions defined:
Each of the three CI actions has nearly identical structure:
on:
definitions to determine when the action should runenv:
variables that may no longer be neededjobs
to execute the following actionssetup
to install Node.js, cache node modules, and install project dependencieslint
(depends on setup) to lint the codeunit
(depends on setup) to run unit testsbuild
(depends on setup) to run the build processNot only are there duplicate steps within each of the above jobs (such as installing node and project dependencies), it is likely that we no longer need three separate actions.
So, we should determine how best to reorganize our CI script(s) in order to reduce duplication and resource usage as well as making it clear for developers what parts are breaking when there are errors.
Please discuss and upvote the suggestions below to show your support or add modifications. Likewise, feel free to add other proposals.
Beta Was this translation helpful? Give feedback.
All reactions