diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000..0e74b6cfa --- /dev/null +++ b/.github/workflows/e2e.yml @@ -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 diff --git a/ci/download-release-artifacts.sh b/ci/download-release-artifacts.sh index d4615c400..362a9bf2d 100755 --- a/ci/download-release-artifacts.sh +++ b/ci/download-release-artifacts.sh @@ -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 diff --git a/docker-compose.e2e.yml b/docker-compose.e2e.yml index fe5675f1c..f71b9c4c0 100644 --- a/docker-compose.e2e.yml +++ b/docker-compose.e2e.yml @@ -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 diff --git a/package.json b/package.json index edd4d2cac..163c930fc 100644 --- a/package.json +++ b/package.json @@ -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, diff --git a/test/e2e/ipfs-companion.test.js b/test/e2e/ipfs-companion.test.js index 53fd28749..8853625ac 100644 --- a/test/e2e/ipfs-companion.test.js +++ b/test/e2e/ipfs-companion.test.js @@ -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'))