Skip to content

Commit

Permalink
Merge pull request #1401 from ethereumjs/ci-cache-refactor
Browse files Browse the repository at this point in the history
ci: simplify dependency cache code
  • Loading branch information
holgerd77 authored Aug 12, 2021
2 parents 66d02e1 + 32efabf commit e2a0a4d
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 466 deletions.
26 changes: 7 additions & 19 deletions .github/workflows/block-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,20 @@ jobs:
matrix:
node-version: [12]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Update to npm v7 for workspaces support
- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/blockchain-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,20 @@ jobs:
matrix:
node-version: [12]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Update to npm v7 for workspaces support
- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand Down
48 changes: 12 additions & 36 deletions .github/workflows/client-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,20 @@ jobs:
matrix:
node-version: [12]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand All @@ -67,32 +55,20 @@ jobs:
syncmode: ['full', 'light']
fail-fast: false
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache

- name: Use Node.js 12
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: 12
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run test:cli -- --network=${{matrix.network}} --syncmode=${{matrix.syncmode}} --transports rlpx
22 changes: 5 additions & 17 deletions .github/workflows/common-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,20 @@ jobs:
matrix:
node-version: [12]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/devp2p-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,20 @@ jobs:
matrix:
node-version: [12]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand Down
25 changes: 6 additions & 19 deletions .github/workflows/e2e-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,21 @@ jobs:
matrix:
node-version: [16]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: actions/checkout@v2
with:
submodules: recursive

# Use a dependency cache to speed up runs of same deps
- name: Dependency cache
uses: actions/cache@v2
id: cache
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Build if cache is restored
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'

# Otherwise, run install (which also runs build)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
- run: npm i
working-directory: ${{github.workspace}}

# Publish all packages to virtual npm registry
# after giving each a minor version bump
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/ethash-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,20 @@ jobs:
matrix:
node-version: [12]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Dependency cache
uses: actions/cache@v2
id: cache
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
key: cache-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
path: '**/node_modules'
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

# Installs dependencies and builds all packages (if cache hit failed)
- run: npm install
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}

# Builds fresh packages (if cache hit succeeded)
- run: npm run build --workspaces
if: steps.cache.outputs.cache-hit == 'true'
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/node-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- uses: actions/checkout@v2
with:
submodules: recursive
node-version: 12

- id: set-matrix
run: echo "::set-output name=matrix::$(npx testable-node-versions)"
Expand All @@ -34,18 +30,20 @@ jobs:
node: ${{ fromJson(needs.get-node-versions.outputs.matrix) }}
fail-fast: false
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- uses: actions/checkout@v2
with:
submodules: recursive

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Use npm v7 for workspaces support
run: npm i -g npm@7

- run: npm install
- run: npm i

- name: Test Block
run: npm run test
Expand Down
Loading

0 comments on commit e2a0a4d

Please sign in to comment.