Skip to content

Commit

Permalink
chore: Enhanced GA CI with cache
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Sep 5, 2024
1 parent e41567e commit 98ec1bb
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 37 deletions.
14 changes: 14 additions & 0 deletions .github/actions/build_argos_desktop_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Cache Argos desktop"

runs:
using: "composite"
steps:
- name: Cache Argos desktop
id: cache-argos-desktop
uses: actions/cache@v3
env:
cache-name: cache-argos-desktop
with:
path: |
${{ github.workspace }}/screenshots/reactDesktop
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
14 changes: 14 additions & 0 deletions .github/actions/build_argos_kss_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Cache Argos kss"

runs:
using: "composite"
steps:
- name: Cache Argos kss
id: cache-argos-kss
uses: actions/cache@v3
env:
cache-name: cache-argos-kss
with:
path: |
${{ github.workspace }}/screenshots/kss
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
14 changes: 14 additions & 0 deletions .github/actions/build_argos_mobile_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Cache Argos mobile"

runs:
using: "composite"
steps:
- name: Cache Argos mobile
id: cache-argos-mobile
uses: actions/cache@v3
env:
cache-name: cache-argos-mobile
with:
path: |
${{ github.workspace }}/screenshots/reactMobile
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
18 changes: 18 additions & 0 deletions .github/actions/build_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Cache builds"

runs:
using: "composite"
steps:
- name: Cache builds
id: cache-builds
uses: actions/cache@v3
env:
cache-name: cache-builds
with:
path: |
${{ github.workspace }}/react/Icon/icons-sprites.js
${{ github.workspace }}/react/palette.js
${{ github.workspace }}/transpiled
${{ github.workspace }}/dist
${{ github.workspace }}/build
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
18 changes: 18 additions & 0 deletions .github/actions/build_cache_read/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Read builds cache"

runs:
using: "composite"
steps:
- name: Read builds cache
id: cache-builds-read
uses: actions/cache/restore@v3
env:
cache-name: cache-builds
with:
path: |
${{ github.workspace }}/react/Icon/icons-sprites.js
${{ github.workspace }}/react/palette.js
${{ github.workspace }}/transpiled
${{ github.workspace }}/dist
${{ github.workspace }}/build
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
20 changes: 20 additions & 0 deletions .github/actions/setup_argos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Setup Argos"

runs:
using: "composite"
steps:
- uses: ./.github/actions/setup_modules
- name: Cache puppeteer
id: cache-node-modules-puppeteer
uses: actions/cache@v3
env:
cache-name: cache-node-modules-puppeteer
with:
path: |
${{ github.workspace }}/node_modules
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Argos - Prepare env
if: ${{ steps.cache-node-modules-puppeteer.outputs.cache-hit != 'true' }}
shell: bash
run: |
yarn add puppeteer@"21.11.0" --dev --exact
21 changes: 21 additions & 0 deletions .github/actions/setup_modules/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Setup modules"

runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
${{ github.workspace }}/node_modules
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
- name: Install packages
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
shell: bash
run: yarn install --frozen-lockfile
138 changes: 102 additions & 36 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,111 @@ env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_modules
prepareArgos:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_argos
build:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# - name: Install packages
# run: yarn install --frozen-lockfile
# - name: Lint
# run: yarn lint
# - name: Build JS/CSS/DOCS
# run: yarn build:all
# - name: Tests without snapshots
# run: yarn test:noSnapshots
# - name: Tests snapshots
# run: yarn test:snapshots
# # - name: Bundlemon
# # run: yarn bundlemon
# - name: Argos - Prepare env
# run: |
# yarn add puppeteer@"21.11.0" --dev --exact
# mkdir ./screenshots
# - name: Argos - Create desktop screenshots
# run: yarn screenshots --mode react --viewport desktop --screenshot-dir ./screenshots/reactDesktop
# - name: Argos - Create mobile screenshots
# run: yarn screenshots --mode react --viewport 300x600 --screenshot-dir ./screenshots/reactMobile
# - name: Argos - Create kss screenshots
# run: yarn screenshots --mode kss --screenshot-dir ./screenshots/kss
# - name: Argos - Upload all screenshots
# run: |
# UUID=$(uuidgen)
# yarn argos:upload --parallel screenshots/reactDesktop/ --token $ARGOS_TOKEN --parallel-total 3 --parallel-nonce $GITHUB_RUN_ID-${UUID} --ignore ''
# yarn argos:upload --parallel screenshots/reactMobile/ --token $ARGOS_TOKEN --parallel-total 3 --parallel-nonce $GITHUB_RUN_ID-${UUID} --ignore ''
# yarn argos:upload --parallel screenshots/kss/ --token $ARGOS_TOKEN --parallel-total 3 --parallel-nonce $GITHUB_RUN_ID-${UUID} --ignore ''
# - name: Deploy
# if: ${{ github.ref_name == 'master' }}
# run: |
# yarn deploy:doc --username cozycloud --email [email protected] --repo https://cozy-bot:[email protected]/cozy/cozy-ui.git
# yarn semantic-release
- uses: ./.github/actions/setup_modules
- uses: ./.github/actions/build_cache
- name: Lint
run: yarn lint
- name: Generate Sprite and Palette
run: yarn makeSpriteAndPalette
- name: Build JS
run: yarn build
- name: Build CSS
run: yarn build:css:all
- name: Build docs
run: |
yarn build:doc:react
yarn build:doc:kss
test:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_modules
- uses: ./.github/actions/build_cache_read
- name: Tests without snapshots
run: yarn test:noSnapshots
- name: Tests snapshots
run: yarn test:snapshots
# - name: Bundlemon
# run: yarn bundlemon
argosDesktop:
needs: [prepareArgos, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_argos
- uses: ./.github/actions/build_cache
- uses: ./.github/actions/build_argos_desktop_cache
- name: Argos - Create desktop screenshots
run: |
mkdir ./screenshots
yarn screenshots --mode react --viewport desktop --screenshot-dir ./screenshots/reactDesktop
argosMobile:
needs: [prepareArgos, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_argos
- uses: ./.github/actions/build_cache
- uses: ./.github/actions/build_argos_mobile_cache
- name: Argos - Create mobile screenshots
run: |
mkdir ./screenshots
yarn screenshots --mode react --viewport 300x600 --screenshot-dir ./screenshots/reactMobile
argosKss:
needs: [prepareArgos, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_argos
- uses: ./.github/actions/build_cache
- uses: ./.github/actions/build_argos_kss_cache
- name: Argos - Create kss screenshots
run: |
mkdir ./screenshots
yarn screenshots --mode kss --screenshot-dir ./screenshots/kss
argosUpload:
needs: [argosDesktop, argosMobile, argosKss]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_argos
- uses: ./.github/actions/build_argos_desktop_cache
- uses: ./.github/actions/build_argos_mobile_cache
- uses: ./.github/actions/build_argos_kss_cache
- name: Argos - Upload all screenshots
run: |
UUID=$(uuidgen)
yarn argos:upload --parallel screenshots/reactDesktop/ --token $ARGOS_TOKEN --parallel-total 3 --parallel-nonce $GITHUB_RUN_ID-${UUID} --ignore ''
yarn argos:upload --parallel screenshots/reactMobile/ --token $ARGOS_TOKEN --parallel-total 3 --parallel-nonce $GITHUB_RUN_ID-${UUID} --ignore ''
yarn argos:upload --parallel screenshots/kss/ --token $ARGOS_TOKEN --parallel-total 3 --parallel-nonce $GITHUB_RUN_ID-${UUID} --ignore ''
deploy:
needs: [argosUpload, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_modules
- uses: ./.github/actions/build_cache
- name: Deploy
if: ${{ github.ref_name == 'master' }}
run: |
yarn deploy:doc --username cozycloud --email [email protected] --repo https://cozy-bot:[email protected]/cozy/cozy-ui.git
yarn semantic-release
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
"prettier": "2.6.0",
"pretty": "2.0.0",
"prop-types": "15.7.2",
"puppeteer-core": "22.15.0",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-hot-loader": "^4.3.11",
Expand Down

0 comments on commit 98ec1bb

Please sign in to comment.