Skip to content

Commit

Permalink
Run e2e tests on GH actions (#12517)
Browse files Browse the repository at this point in the history
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Juan Picado <juanpicado19@gmail.com>
  • Loading branch information
3 people committed Mar 12, 2021
1 parent 71417bb commit 05fa18e
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 81 deletions.
84 changes: 14 additions & 70 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,6 @@ jobs:
- store_test_results: *artifact_test262_xunit
- save_cache: *save-yarn-cache

publish-verdaccio:
executor: node-executor
steps:
- checkout
- restore_cache: *restore-yarn-cache
- run: ./scripts/integration-tests/publish-local.sh
- persist_to_workspace:
root: /tmp/verdaccio-workspace
paths:
- storage
- htpasswd
- save_cache: *save-yarn-cache

publish-verdaccio-babel-8-breaking:
executor: node-executor
steps:
Expand All @@ -141,39 +128,23 @@ jobs:
- htpasswd
- save_cache: *save-yarn-cache

e2e-babel:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-babel.sh

e2e-babel-breaking:
e2e-breaking-babel:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: BABEL_8_BREAKING=true ./scripts/integration-tests/e2e-babel.sh

e2e-babel-old-version:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-babel-old-version.sh

e2e-create-react-app:
e2e-breaking-create-react-app:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-create-react-app.sh
- run: BABEL_8_BREAKING=true ./scripts/integration-tests/e2e-create-react-app.sh

e2e-vue-cli:
e2e-breaking-vue-cli:
executor: node-browsers-executor
steps:
- checkout
Expand All @@ -183,17 +154,9 @@ jobs:
# vue-cli uses puppeteer, and it depends on the libXss.so.1 shared library
name: Install Headless Chrome dependencies
command: sudo apt-get install -yq libxss1
- run: ./scripts/integration-tests/e2e-vue-cli.sh

e2e-jest:
executor: node-python-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-jest.sh
- run: BABEL_8_BREAKING=true ./scripts/integration-tests/e2e-vue-cli.sh

e2e-jest-breaking:
e2e-breaking-jest:
executor: node-python-executor
steps:
- checkout
Expand Down Expand Up @@ -238,41 +201,23 @@ workflows:
- next-8-dev
- next-8-rebased
context: babel-test262
e2e:
jobs:
- publish-verdaccio
- e2e-babel:
requires:
- publish-verdaccio
- e2e-babel-old-version:
requires:
- publish-verdaccio
- e2e-create-react-app:
requires:
- publish-verdaccio
- e2e-vue-cli:
requires:
- publish-verdaccio
- e2e-jest:
requires:
- publish-verdaccio

e2e-breaking:
jobs:
- publish-verdaccio-babel-8-breaking:
filters:
branches:
only: [main, next-8-dev, next-8-rebased]
- e2e-babel-breaking:
- e2e-breaking-babel:
requires:
- publish-verdaccio-babel-8-breaking
- e2e-create-react-app:
- e2e-breaking-create-react-app:
requires:
- publish-verdaccio-babel-8-breaking
- e2e-vue-cli:
- e2e-breaking-vue-cli:
requires:
- publish-verdaccio-babel-8-breaking
- e2e-jest-breaking:
- e2e-breaking-jest:
requires:
- publish-verdaccio-babel-8-breaking

Expand All @@ -286,16 +231,15 @@ workflows:
- publish-verdaccio-babel-8-breaking:
requires:
- approve-e2e-breaking-run
- e2e-babel-breaking:
- e2e-breaking-babel:
requires:
- publish-verdaccio-babel-8-breaking
- e2e-create-react-app:
- e2e-breaking-create-react-app:
requires:
- publish-verdaccio-babel-8-breaking
- e2e-vue-cli:
- e2e-breaking-vue-cli:
requires:
- publish-verdaccio-babel-8-breaking
- e2e-jest-breaking:
- e2e-breaking-jest:
requires:
- publish-verdaccio-babel-8-breaking

52 changes: 51 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ jobs:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('yarn.lock') }}
# See https://github.com/babel/babel/pull/12906
- name: Workaround yarn bug
- name: Support self-references on old Node.js
run: |
echo '{
"private": true,
Expand Down Expand Up @@ -365,3 +365,53 @@ jobs:
node-version: 14.2
- name: Test Node.js 14.2
run: yarn test:runtime:node

e2e-publish:
name: Publish to local Verdaccio registry
needs: prepare-yarn-cache
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "*"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Setup Yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('yarn.lock') }}
- name: Publish
run: ./scripts/integration-tests/publish-local.sh
- uses: actions/upload-artifact@v2
with:
name: verdaccio-workspace
path: /tmp/verdaccio-workspace

e2e-tests:
name: E2E
needs: e2e-publish
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [babel, babel-old-version, create-react-app, vue-cli, jest]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "*"
- uses: actions/download-artifact@v2
with:
name: verdaccio-workspace
path: /tmp/verdaccio-workspace
- name: Test
run: ./scripts/integration-tests/e2e-${{ matrix.project }}.sh
9 changes: 6 additions & 3 deletions scripts/integration-tests/e2e-babel-old-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ cd ../..
startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml

node "$PWD"/scripts/integration-tests/utils/bump-babel-dependencies.js

(
yarn why @babel/core | grep -o "@babel/core@npm:.* (via npm:.*)";
yarn why @babel/helpers | grep -o "@babel/helpers@npm:.* (via npm:.*)";
yarn why @babel/traverse | grep -o "@babel/traverse@npm:.* (via npm:.*)"
# Yarn prints colors on GH actions even if it's piped, unless explicitly disabled
# https://github.com/yarnpkg/berry/pull/659
YARN_ENABLE_COLORS=0 yarn why @babel/core | grep -o "@babel/core@npm:.* (via npm:.*)";
YARN_ENABLE_COLORS=0 yarn why @babel/helpers | grep -o "@babel/helpers@npm:.* (via npm:.*)";
YARN_ENABLE_COLORS=0 yarn why @babel/traverse | grep -o "@babel/traverse@npm:.* (via npm:.*)"
) | uniq | node -e "
var pkg = require('./package.json');
var packages = fs.readFileSync(0, 'utf8').trim().split('\n');
Expand Down
4 changes: 2 additions & 2 deletions scripts/integration-tests/publish-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ yarn
startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml
loginLocalRegistry

# This script gets the last @babel/standalone version (because it's always published),
# This script gets the last root package.json version,
# and then increases by one the patch number
VERSION=$(
node -p "'$(npm view @babel/standalone version)'.replace(/(?<=\\d+\\.\\d+\\.)\\d+/, x => ++x)"
node -p "require('./package.json').version.replace(/(?<=\\d+\\.\\d+\\.)\\d+/, x => ++x)"
)

I_AM_USING_VERDACCIO=I_AM_SURE VERSION="$VERSION" make publish-test
Expand Down
4 changes: 2 additions & 2 deletions scripts/integration-tests/utils/local-registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# Copied from https://github.com/facebook/create-react-app/blob/053f9774d3f592c17741d2a86de66a7ca58f90c0/tasks/local-registry.sh

custom_registry_url=http://localhost:4873
default_verdaccio_package=verdaccio@~4.3.3
default_verdaccio_package=verdaccio@~4.11.1

function startLocalRegistry {
# Start local registry
tmp_registry_log=`mktemp`
echo "Registry output file: $tmp_registry_log"
(cd && nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &)

yarn global add verdaccio-memory@~9.7.2
# Wait for Verdaccio to boot
grep -q "http address" <(tail -f $tmp_registry_log)

Expand Down
6 changes: 3 additions & 3 deletions scripts/integration-tests/verdaccio-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ uplinks:
url: https://registry.npmjs.org/

packages:
'@*/*':
"@*/*":
# scoped packages
access: $all
publish: $all
unpublish: $all
proxy: npmjs

'**':
"**":
# allow all users (including non-authenticated users) to read and
# publish all packages
#
Expand All @@ -54,7 +54,7 @@ middlewares:

# log settings
logs:
- { type: stdout, format: pretty, level: http }
- { type: stdout, format: pretty, level: warn }
#- {type: file, path: verdaccio.log, level: info}
#experiments:
# # support for npm token command
Expand Down

0 comments on commit 05fa18e

Please sign in to comment.