From ceed10146010887c5d688e18289ad2a0ca1af854 Mon Sep 17 00:00:00 2001 From: Alexandre Hajjar Date: Wed, 2 Jun 2021 18:16:57 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Run=20external-integration=20tests?= =?UTF-8?q?=20in=20separate=20ghaction=20cron-style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create new Github Action * Install cypress packages from mon-entreprise dev dependencies --- .github/workflows/deploy.yaml | 14 +------- .../workflows/test-external-integrations.yaml | 33 +++++++++++++++++++ mon-entreprise/package.json | 1 + .../scripts/get-cypress-packages.js | 10 ++++++ package.json | 1 - yarn.lock | 6 ++-- 6 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/test-external-integrations.yaml create mode 100644 mon-entreprise/scripts/get-cypress-packages.js diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e5187a9d8..50e53eec3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -173,7 +173,6 @@ jobs: integrationFolder: mon-entreprise baseUrl: ${{ needs.deploy-context.outputs.fr_url }} language: fr - test-external: ${{ needs.deploy-context.outputs.env-name == 'master' }} - site: en integrationFolder: mon-entreprise baseUrl: ${{ needs.deploy-context.outputs.en_url }} @@ -197,7 +196,7 @@ jobs: ~/.cache/Cypress node_modules key: cypress-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }} - - run: npm i cypress cypress-plugin-tab + - run: node mon-entreprise/scripts/get-cypress-packages.js | xargs npm i - name: Test mon-entreprise uses: cypress-io/github-action@v2 with: @@ -209,14 +208,3 @@ jobs: env: language=${{ matrix.language }} env: COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} - - - name: Test external integration - if: matrix.test-external - uses: cypress-io/github-action@v2 - with: - install: false - working-directory: mon-entreprise - record: true - tag: external-integration - config: integrationFolder=cypress/integration/external,baseUrl=${{ matrix.baseUrl }} - \ No newline at end of file diff --git a/.github/workflows/test-external-integrations.yaml b/.github/workflows/test-external-integrations.yaml new file mode 100644 index 000000000..74b11ea84 --- /dev/null +++ b/.github/workflows/test-external-integrations.yaml @@ -0,0 +1,33 @@ +name: Test external integrations +on: + schedule: + - cron: '47 3,15 * * *' + +jobs: + test-external-integrations: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + runs-on: ubuntu-16.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: actions/cache@v2 + # Custom cache as we do not care about installing all the other dependancies + with: + path: | + ~/.cache/Cypress + node_modules + key: cypress-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + + - run: node mon-entreprise/scripts/get-cypress-packages.js | xargs npm i + + - name: Test external integration + uses: cypress-io/github-action@v2 + with: + install: false + working-directory: mon-entreprise + record: true + tag: external-integration + config: integrationFolder=cypress/integration/external,baseUrl=https://mon-entreprise.fr diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index 3c830f513..65ea048e0 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -43,6 +43,7 @@ "autoprefixer": "^9.7.6", "babel-plugin-styled-components": "^1.10.7", "copy-webpack-plugin": "^4.5.2", + "cypress": "^7.4.0", "cypress-plugin-tab": "^1.0.5", "eslint-plugin-react": "^7.12.4", "html-webpack-plugin": "^3.2.0", diff --git a/mon-entreprise/scripts/get-cypress-packages.js b/mon-entreprise/scripts/get-cypress-packages.js new file mode 100644 index 000000000..c1b4d3f17 --- /dev/null +++ b/mon-entreprise/scripts/get-cypress-packages.js @@ -0,0 +1,10 @@ +const fs = require('fs') + +const packages = JSON.parse(fs.readFileSync(`${__dirname}/../package.json`)) + +console.log('cypress@' + packages.devDependencies.cypress) +for (const key of Object.keys(packages.devDependencies).filter( + (k) => k !== 'cypress' && k.startsWith('cypress') +)) { + console.log(key + '@' + packages.devDependencies[key]) +} diff --git a/package.json b/package.json index aafd1f36a..0f5f8aeff 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,6 @@ }, "optionalDependencies": { "bundlesize": "^0.18.0", - "cypress": "^7.4.0", "prerender-spa-plugin": "^3.4.0" }, "scripts": { diff --git a/yarn.lock b/yarn.lock index 359986f7e..67c7dac59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2378,9 +2378,9 @@ integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA== "@types/node@^14.14.31": - version "14.17.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.1.tgz#5e07e0cb2ff793aa7a1b41deae76221e6166049f" - integrity sha512-/tpUyFD7meeooTRwl3sYlihx2BrJE7q9XF71EguPFIySj9B7qgnRtHsHTho+0AUm4m1SvWGm6uSncrR94q6Vtw== + version "14.17.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.2.tgz#1e94476db57ec93a372c7f7d29aa5707cfb92339" + integrity sha512-sld7b/xmFum66AAKuz/rp/CUO8+98fMpyQ3SBfzzBNGMd/1iHBTAg9oyAvcYlAj46bpc74r91jSw2iFdnx29nw== "@types/normalize-package-data@^2.4.0": version "2.4.0"