Skip to content

Commit

Permalink
Merge pull request #606 from golemfactory/chore/scratch-goth
Browse files Browse the repository at this point in the history
Scratch Goth from tests
  • Loading branch information
cryptobench authored Oct 6, 2023
2 parents 8dd67e1 + 7507252 commit fc9f785
Show file tree
Hide file tree
Showing 23 changed files with 388 additions and 417 deletions.
63 changes: 16 additions & 47 deletions .github/workflows/cypress-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,37 @@ on:

jobs:
cypress-tests:
runs-on: [goth2, ubuntu-22.10]
runs-on: goth2
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Use random string for subnet
run: echo "YAGNA_SUBNET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '')" >> $GITHUB_ENV

- name: Install browsers and graphic environment
run: |
sudo apt-get update -y
sudo apt-get install -y build-essential
sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install --allow-downgrades -y ./google-chrome-stable_current_amd64.deb
- name: Build the docker containers
# Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2
run: docker compose -f tests/docker/docker-compose.yml build

- name: Build the SDK
run: |
npm install
npm run build
- name: Start the docker containers
# Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2
run: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d

- name: Configure python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Fund the requestor
# Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry.
run: sleep 4 && docker exec -t docker-requestor-1 /bin/sh -c "/golem-js/tests/docker/fundRequestor.sh"

- name: Install goth
- name: Install and build the SDK in the docker container
run: |
pip install goth
rm -rf ../goth/assets
python -m goth create-assets ../goth/assets
sed -Ezi 's/(use\-proxy:\s)(True)/\1False/mg' ../goth/assets/goth-config.yml
sed -Ezi 's/(use\-prerelease:\s)(false)/\1true\n release-tag: "0.13.0-rc10"/mg' ../goth/assets/goth-config.yml
sed -i '/^ENTRYPOINT/i ENV YAGNA_AUTOCONF_APPKEY=try_golem' ../goth/assets/docker/yagna-goth-deb.Dockerfile
- name: Cleanup Docker
if: always()
run: |
c=$(docker ps -q) && [[ $c ]] && docker kill $c
docker system prune -af
- name: Log in to GitHub Docker repository
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run build && ./node_modules/.bin/cypress install"
- name: Run web server
run: |
cd examples/web
node app.mjs &
docker exec -t -d docker-requestor-1 /bin/sh -c "cd /golem-js/examples/web && node app.mjs"
- name: Run test suite
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run test:cypress -- --browser chrome
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm run test:cypress -- --browser chromium"
- name: Upload test logs
uses: actions/upload-artifact@v2
Expand All @@ -75,11 +49,6 @@ jobs:
name: cypress-logs
path: .cypress

# Only relevant for self-hosted runners
- name: Remove test logs
if: always()
run: rm -rf .cypress

- name: Cleanup Docker
if: always()
run: |
Expand Down
65 changes: 16 additions & 49 deletions .github/workflows/examples-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: echo "::set-output name=matrix::{\"include\":[{\"branch\":\"master\"}]}"

goth-tests:
runs-on: [goth2, ubuntu-22.10]
runs-on: goth2
needs: prepare-matrix-master-only
strategy:
matrix: ${{ fromJson(needs.prepare-matrix-master-only.outputs.matrix-json) }}
Expand All @@ -31,61 +31,28 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Configure node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Use random string for subnet
run: echo "YAGNA_SUBNET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '')" >> $GITHUB_ENV

- name: Build golem-js
run: |
sudo apt-get update -y
sudo apt-get install -y build-essential
npm install
npm run build
npm install --prefix examples
npm install ts-node
- name: Build the docker containers
# Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2
run: docker compose -f tests/docker/docker-compose.yml build

- name: Configure python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Start the docker containers
# Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2
run: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d

- name: Install goth
run: |
pip install goth>=0.15.3
rm -rf ../goth/assets
python -m goth create-assets ../goth/assets
sed -Ezi 's/(use\-proxy:\s)(True)/\1False/mg' ../goth/assets/goth-config.yml
sed -Ezi 's/(use\-prerelease:\s)(false)/\1true\n release-tag: "0.13.0-rc21"/mg' ../goth/assets/goth-config.yml
sed -i '/^ENTRYPOINT/i ENV YAGNA_AUTOCONF_APPKEY=try_golem' ../goth/assets/docker/yagna-goth-deb.Dockerfile
- name: Fund the requestor
# Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry.
run: sleep 4 && docker exec -t docker-requestor-1 /bin/sh -c "/golem-js/tests/docker/fundRequestor.sh"

- name: Cleanup Docker
if: always()
- name: Install and build the SDK in the docker container
run: |
c=$(docker ps -q) && [[ $c ]] && docker kill $c
docker system prune -af
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run build"
- name: Log in to GitHub Docker repository
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin

- name: Run test suite
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run the Examples tests
run: |
npm run test:examples
- name: Upload test logs
uses: actions/upload-artifact@v2
if: always()
with:
name: goth-logs
path: /tmp/goth-tests

# Only relevant for self-hosted runners
- name: Remove test logs
if: always()
run: rm -rf /tmp/goth-tests
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm install --prefix examples && npm install ts-node && npm run test:examples -- --exitOnError"
- name: Cleanup Docker
if: always()
Expand Down
69 changes: 16 additions & 53 deletions .github/workflows/goth-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: echo "::set-output name=matrix::{\"include\":[{\"branch\":\"master\"}]}"

goth-tests:
runs-on: [goth2, ubuntu-22.10]
runs-on: goth2
needs: prepare-matrix-master-only
strategy:
matrix: ${{ fromJson(needs.prepare-matrix-master-only.outputs.matrix-json) }}
Expand All @@ -31,64 +31,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Configure node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Use random string for subnet
run: echo "YAGNA_SUBNET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '')" >> $GITHUB_ENV

- name: Build golem-js
run: |
sudo apt-get update -y
sudo apt-get install -y build-essential
npm install
npm run build
- name: Configure python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install goth
run: |
pip install goth
rm -rf ../goth/assets
python -m goth create-assets ../goth/assets
sed -Ezi 's/(use\-proxy:\s)(True)/\1False/mg' ../goth/assets/goth-config.yml
sed -Ezi 's/(use\-prerelease:\s)(false)/\1true\n release-tag: "0.13.0-rc10"/mg' ../goth/assets/goth-config.yml
- name: Build the docker containers
# Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2
run: docker compose -f tests/docker/docker-compose.yml build

- name: Install websocat and sshpass
run: |
sudo wget https://github.com/vi/websocat/releases/download/v1.9.0/websocat_linux64 -O /usr/local/bin/websocat
sudo chmod +x /usr/local/bin/websocat
sudo apt-get install sshpass
- name: Cleanup Docker
if: always()
run: |
c=$(docker ps -q) && [[ $c ]] && docker kill $c
docker system prune -af
- name: Start the docker containers
# Use a random string to avoid other providers on the same subnet which might cause tests to fail because it expects only providers named provider-1 and provider-2
run: docker compose -f tests/docker/docker-compose.yml down && docker compose -f tests/docker/docker-compose.yml up -d

- name: Log in to GitHub Docker repository
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin
- name: Fund the requestor
# Use a funding script which will retry funding the requestor 3 times, else it exits with error. The faucet is not reliable and sometimes fails to fund the requestor, thus the retry.
run: sleep 4 && docker exec -t docker-requestor-1 /bin/sh -c "/golem-js/tests/docker/fundRequestor.sh"

- name: Run test suite
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install and build the SDK in the docker container
run: |
npm run test:e2e
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run build"
- name: Upload test logs
uses: actions/upload-artifact@v2
if: always()
with:
name: goth-logs
path: /tmp/goth-tests

# Only relevant for self-hosted runners
- name: Remove test logs
if: always()
run: rm -rf /tmp/goth-tests
- name: Start the e2e test
run: docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run test:e2e"

- name: Cleanup Docker
if: always()
Expand Down
Loading

0 comments on commit fc9f785

Please sign in to comment.