Skip to content

Commit

Permalink
feat: create a workflow for running e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Dec 20, 2022
1 parent 00d14ea commit 5a933cd
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 6 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: e2e
on:
workflow_dispatch:
inputs:
firefox-version:
description: The version of selenium/standalone-firefox image to use
default: latest
required: true
chromium-version:
description: The version of selenium/standalone-chrome image to use
default: latest
required: true
kubo-version:
description: The version of ipfs/kubo image to use
default: latest
required: true
ipfs-companion-version:
description: The version of ipfs-companion extension to use (defaults to building the extension from source)
default: ''
required: false

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Download ipfs-companion
if: inputs.ipfs-companion-version != ''
run: ./ci/download-release-artifacts.sh
env:
IPFS_COMPANION_VERSION: ${{ inputs.ipfs-companion-version }}
- name: Build ipfs-companion
if: inputs.ipfs-companion-version == ''
run: npm run release-build
- name: Prepare E2E env
run: npm run compose:e2e:prepare
env:
FIREFOX_VERSION: ${{ inputs.firefox-version }}
CHROMIUM_VERSION: ${{ inputs.chromium-version }}
KUBO_VERSION: ${{ inputs.kubo-version }}
- name: Start E2E env
run: npm run compose:e2e:up
env:
FIREFOX_VERSION: ${{ inputs.firefox-version }}
CHROMIUM_VERSION: ${{ inputs.chromium-version }}
KUBO_VERSION: ${{ inputs.kubo-version }}
- name: Wait for E2E env set up to complete
run: sleep 60
- name: Run E2E tests
run: npm run compose:e2e:test
env:
IPFS_COMPANION_VERSION: ${{ inputs.ipfs-companion-version }}
- name: Stop E2E env
run: npm run compose:e2e:down
2 changes: 2 additions & 0 deletions ci/download-release-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ IPFS_COMPANION_VERSION=${IPFS_COMPANION_VERSION:-$(jq -r '.version' ./add-on/man
id="$(curl --retry 5 --no-progress-meter "https://api.github.com/repos/ipfs/ipfs-companion/releases/tags/v$IPFS_COMPANION_VERSION" | jq '.id')"
assets="$(curl --retry 5 --no-progress-meter --location "https://api.github.com/repos/ipfs/ipfs-companion/releases/$id/assets" | jq -r '.[].name')"

mkdir build

for asset in $assets; do
curl --retry 5 --no-progress-meter --location --output "build/$asset" "https://github.com/ipfs/ipfs-companion/releases/download/v$IPFS_COMPANION_VERSION/$asset"
done
1 change: 1 addition & 0 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- CUSTOM_GATEWAY_URL=http://kubo:8080
- TEST_E2E=1
- TEST_HEADLESS=${TEST_HEADLESS}
- TEST_DEBUG=${TEST_DEBUG}
- IPFS_COMPANION_VERSION=${IPFS_COMPANION_VERSION}
volumes:
- ./build:/home/node/app/build
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
"ci:build": "npm run build",
"ci:test": "npm test",
"ci:lint": "npm run lint",
"beta-build": "docker rmi -f ipfs-companion-beta-build && docker build -t ipfs-companion-beta-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm -it --net=host -e RELEASE_CHANNEL=beta -v $(pwd)/build:/home/node/app/build ipfs-companion-beta-build npm run ci:build",
"release-build": "docker rmi -f ipfs-companion-release-build && docker build -t ipfs-companion-release-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm -it --net=host -e RELEASE_CHANNEL=stable -v $(pwd)/build:/home/node/app/build ipfs-companion-release-build npm run ci:build",
"beta-build": "docker rmi -f ipfs-companion-beta-build && docker build -t ipfs-companion-beta-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm --net=host -e RELEASE_CHANNEL=beta -v $(pwd)/build:/home/node/app/build ipfs-companion-beta-build npm run ci:build",
"release-build": "docker rmi -f ipfs-companion-release-build && docker build -t ipfs-companion-release-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm --net=host -e RELEASE_CHANNEL=stable -v $(pwd)/build:/home/node/app/build ipfs-companion-release-build npm run ci:build",
"dev-build": "npm ci && npm run build",
"yarn-build": "npm run dev-build",
"compose:e2e:build": "docker compose --file docker-compose.e2e.yml build",
"compose:e2e:prepare": "docker compose --file docker-compose.e2e.yml pull && docker compose --file docker-compose.e2e.yml build",
"compose:e2e:up": "docker compose --file docker-compose.e2e.yml up --remove-orphans --detach kubo chromium firefox",
"compose:e2e:test": "docker compose --file docker-compose.e2e.yml run e2e npm run test:e2e",
"compose:e2e:stop": "docker compose --file docker-compose.e2e.yml stop"
"compose:e2e:down": "docker compose --file docker-compose.e2e.yml down"
},
"private": true,
"preferGlobal": false,
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/ipfs-companion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ async function getNumberOfConnectedPeers (browser, url) {
console.info(`Going to: ${url}/dist/landing-pages/welcome/index.html`)
await browser.get(`${url}/dist/landing-pages/welcome/index.html`)
await delay(5000) // waiting for the connection number to appear
const html = await browser.getPageSource()
console.debug(html)
if (process.env.TEST_DEBUG === '1') {
const html = await browser.getPageSource()
console.debug(html)
}
console.info('Looking for an element with text: \'Your node is connected to ...\'')
const p = browser.findElement(By.xpath("//p[text()='Your node is connected to ']"))
const span = p.findElement(By.css('span'))
Expand Down

0 comments on commit 5a933cd

Please sign in to comment.