diff --git a/.github/actions/build_argos_desktop_cache/action.yml b/.github/actions/build_argos_desktop_cache/action.yml new file mode 100644 index 0000000000..6682b3e4e0 --- /dev/null +++ b/.github/actions/build_argos_desktop_cache/action.yml @@ -0,0 +1,14 @@ +name: "Cache Argos desktop" + +runs: + using: "composite" + steps: + - name: Cache Argos desktop + id: cache-argos-desktop + uses: actions/cache@v4 + env: + cache-name: cache-argos-desktop + with: + path: | + ${{ github.workspace }}/screenshots/reactDesktop + key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }} diff --git a/.github/actions/build_argos_kss_cache/action.yml b/.github/actions/build_argos_kss_cache/action.yml new file mode 100644 index 0000000000..11054a95c1 --- /dev/null +++ b/.github/actions/build_argos_kss_cache/action.yml @@ -0,0 +1,14 @@ +name: "Cache Argos kss" + +runs: + using: "composite" + steps: + - name: Cache Argos kss + id: cache-argos-kss + uses: actions/cache@v4 + env: + cache-name: cache-argos-kss + with: + path: | + ${{ github.workspace }}/screenshots/kss + key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }} diff --git a/.github/actions/build_argos_mobile_cache/action.yml b/.github/actions/build_argos_mobile_cache/action.yml new file mode 100644 index 0000000000..e0e3486dd4 --- /dev/null +++ b/.github/actions/build_argos_mobile_cache/action.yml @@ -0,0 +1,14 @@ +name: "Cache Argos mobile" + +runs: + using: "composite" + steps: + - name: Cache Argos mobile + id: cache-argos-mobile + uses: actions/cache@v4 + env: + cache-name: cache-argos-mobile + with: + path: | + ${{ github.workspace }}/screenshots/reactMobile + key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }} diff --git a/.github/actions/build_cache/action.yml b/.github/actions/build_cache/action.yml new file mode 100644 index 0000000000..10e9283937 --- /dev/null +++ b/.github/actions/build_cache/action.yml @@ -0,0 +1,18 @@ +name: "Cache builds" + +runs: + using: "composite" + steps: + - name: Cache builds + id: cache-builds + uses: actions/cache@v4 + 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 }} diff --git a/.github/actions/build_cache_read/action.yml b/.github/actions/build_cache_read/action.yml new file mode 100644 index 0000000000..791efec896 --- /dev/null +++ b/.github/actions/build_cache_read/action.yml @@ -0,0 +1,18 @@ +name: "Read builds cache" + +runs: + using: "composite" + steps: + - name: Read builds cache + id: cache-builds-read + uses: actions/cache/restore@v4 + 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 }} diff --git a/.github/actions/setup_argos/action.yml b/.github/actions/setup_argos/action.yml new file mode 100644 index 0000000000..07d1b737b3 --- /dev/null +++ b/.github/actions/setup_argos/action.yml @@ -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@v4 + 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@"22.15.0" --dev --exact diff --git a/.github/actions/setup_modules/action.yml b/.github/actions/setup_modules/action.yml new file mode 100644 index 0000000000..f639fd6470 --- /dev/null +++ b/.github/actions/setup_modules/action.yml @@ -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@v4 + 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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 240e538722..0193967c44 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,45 +8,109 @@ 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 contact@cozycloud.cc --repo https://cozy-bot:$GH_TOKEN@github.com/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_read + - uses: ./.github/actions/build_argos_desktop_cache + - name: Argos - Create desktop screenshots + run: | + mkdir -p ./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_read + - uses: ./.github/actions/build_argos_mobile_cache + - name: Argos - Create mobile screenshots + run: | + mkdir -p ./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_read + - uses: ./.github/actions/build_argos_kss_cache + - name: Argos - Create kss screenshots + run: | + mkdir -p ./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_read + - name: Deploy + if: ${{ github.ref_name == 'master' }} + run: yarn deploy:doc --username cozycloud --email contact@cozycloud.cc --repo https://cozy-bot:$GH_TOKEN@github.com/cozy/cozy-ui.git && yarn semantic-release diff --git a/docs/dev.md b/docs/dev.md index d542351621..f9a8ff7bf6 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -24,7 +24,7 @@ You have to change `executablePath` value of `prepareBrowser` function to match ```bash # Screenshot all the components yarn build:all -mkdir ./screenshots +mkdir -p ./screenshots yarn screenshots cp -r screenshots pristine_screenshots diff --git a/package.json b/package.json index c8e7267327..1a689daff0 100644 --- a/package.json +++ b/package.json @@ -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",