From 08f44b478697c77fb25695257fdac8837de98e50 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Thu, 23 Jul 2020 09:52:03 -0700 Subject: [PATCH] Added end to end tests --- .github/workflows/endToEndTests.yml | 40 +++++++++++++++++++ docker/private-npm-registry/conf/config.yaml | 7 +++- .../private-npm-registry/docker-compose.yml | 12 ++---- sourceme.sh | 17 +++++++- workspaces/scripts/publish.js | 2 +- 5 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/endToEndTests.yml diff --git a/.github/workflows/endToEndTests.yml b/.github/workflows/endToEndTests.yml new file mode 100644 index 0000000000..df0d25dfe4 --- /dev/null +++ b/.github/workflows/endToEndTests.yml @@ -0,0 +1,40 @@ +name: Test end to end + +on: + pull_request: + branches: + - develop + - release + push: + branches: + - develop + - release + +jobs: + test-end-to-end: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: echo "::add-path::$(yarn global bin)" + - name: Check out Optic Repo + uses: actions/checkout@v2 + with: + path: ./optic-repo + - name: Release Optic Locally + run: | + source sourceme.sh && optic_local_registry_start + source sourceme.sh && optic_build_and_publish_locally + working-directory: ./optic-repo + - uses: actions/checkout@v2 + with: + repository: opticdev/optic-end-end-tests + token: ${{ secrets.END_TO_END_ACCESS_KEY }} + path: ./tests + - run: npm install + working-directory: ./tests + - run: npm test + working-directory: ./tests + env: + DEBUG: "*,-babel*" # Helps with tracing errors \ No newline at end of file diff --git a/docker/private-npm-registry/conf/config.yaml b/docker/private-npm-registry/conf/config.yaml index f92c742527..c5f7c987aa 100644 --- a/docker/private-npm-registry/conf/config.yaml +++ b/docker/private-npm-registry/conf/config.yaml @@ -1,8 +1,11 @@ -storage: /verdaccio/storage +store: + memory: + limit: 1000 packages: '@useoptic/*': access: $all publish: $all + proxy: npmjs '*/*': access: $all proxy: npmjs @@ -13,4 +16,4 @@ uplinks: npmjs: url: https://registry.npmjs.org/ logs: - - {type: stdout, format: pretty, level: trace} + - {type: stdout, format: pretty, level: trace} \ No newline at end of file diff --git a/docker/private-npm-registry/docker-compose.yml b/docker/private-npm-registry/docker-compose.yml index d343f30004..f720c7b534 100644 --- a/docker/private-npm-registry/docker-compose.yml +++ b/docker/private-npm-registry/docker-compose.yml @@ -1,13 +1,7 @@ version: '2.1' services: verdaccio: - image: verdaccio/verdaccio:4 - container_name: verdaccio-docker-local-storage-vol + image: verdaccio/verdaccio:4.6 + container_name: verdaccio-local-registry ports: - - "4873:4873" - volumes: - - "./storage:/verdaccio/storage" - - "./conf:/verdaccio/conf" -volumes: - verdaccio: - driver: local + - "4873:4873" \ No newline at end of file diff --git a/sourceme.sh b/sourceme.sh index 5ceb1e3f9a..65f834bf89 100755 --- a/sourceme.sh +++ b/sourceme.sh @@ -100,7 +100,8 @@ optic_build_and_publish_locally() { set -o errexit optic_build_for_release cd "$OPTIC_SRC_DIR" - yarn run publish-local + npm-cli-login -u testUser -p testPass -e test@example.com -r http://localhost:4873 + OPTIC_PUBLISH_SCOPE=private node ./workspaces/scripts/publish.js ) } optic_release_and_install_locally() { @@ -127,3 +128,17 @@ optic_install_from_local_registry() { ) } # DEBUG=optic* apidev daemon:stop && DEBUG=optic* apidev agent:start +optic_local_registry_start() { + ( + set -o errexit + cd "$OPTIC_SRC_DIR" + cd docker/private-npm-registry + yarn global add verdaccio-memory npm-cli-login + docker-compose up & + + cd "$OPTIC_SRC_DIR" + yarn install + yarn wait-on http://localhost:4873 + printf "local npm registry started on http://localhost:4873 \n" + ) +} \ No newline at end of file diff --git a/workspaces/scripts/publish.js b/workspaces/scripts/publish.js index c11bd5f7b7..5f238a8620 100644 --- a/workspaces/scripts/publish.js +++ b/workspaces/scripts/publish.js @@ -90,7 +90,7 @@ promise 'npm', isPrivatePublish ? ['publish', '--registry', registry] - : ['publish', '--access', 'public'], + : ['publish', '--access', 'public', '-ddd'], { cwd, stdio: 'inherit',