Skip to content

Commit

Permalink
Merge pull request #711 from golemfactory/beta
Browse files Browse the repository at this point in the history
Release beta to master
  • Loading branch information
grisha87 authored Feb 13, 2024
2 parents e38c925 + 7cee55b commit ddd84a0
Show file tree
Hide file tree
Showing 187 changed files with 23,329 additions and 3,089 deletions.
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,40 @@
{
"checkLoops": false
}
],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "import",
"format": ["camelCase", "PascalCase"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
{
"selector": ["memberLike", "function"],
"format": ["camelCase"],
"leadingUnderscore": "forbid",
"filter": {
"regex": "golem.*", // ProposalProperties like 'golem.com.payment.debit-notes.accept-timeout?'
"match": false
}
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "enumMember",
"format": ["PascalCase"]
},
{
"selector": "objectLiteralProperty",
"format": null // We have too many varrying cases like YAGNA_APPKEY, Authorization, golem.com.scheme.payu.payment-timeout-sec? which break this constantly
}
]
},
"overrides": [
Expand Down
33 changes: 33 additions & 0 deletions .github/actions/cleanup-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Cleanup test environment"
description: "Cleanup test environment"
inputs:
type:
description: "Type of test"
required: true
default: "test"
runs:
using: "composite"
steps:
- name: Collect logs from providers and requestor
shell: bash
if: always()
run: |
mkdir log-output
docker compose -f tests/docker/docker-compose.yml logs provider-1 > log-output/${{inputs.type}}-provider-1.log
docker compose -f tests/docker/docker-compose.yml logs provider-2 > log-output/${{inputs.type}}-provider-2.log
docker compose -f tests/docker/docker-compose.yml logs requestor > log-output/${{inputs.type}}-requestor.log
- name: Upload provider output and logs
uses: actions/upload-artifact@v3
if: always()
with:
name: ${{inputs.type}}-golem-provider-and-requestor-logs
path: log-output

- name: Cleanup Docker
shell: bash
if: always()
run: |
c=$(docker ps -q)
[[ $c ]] && docker kill $c
docker system prune -af
45 changes: 45 additions & 0 deletions .github/actions/prepare-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Prepare providers and requestor"
description: "Prepare providers and requestor"
runs:
using: "composite"
steps:
- name: Use random string for subnet
shell: bash
# 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: echo "YAGNA_SUBNET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '')" >> $GITHUB_ENV

- name: Set up Versions
shell: bash
run: |
echo "PROVIDER_VERSION=${PROVIDER_VERSION}" >> $GITHUB_ENV
echo "REQUESTOR_VERSION=${REQUESTOR_VERSION}" >> $GITHUB_ENV
echo "PROVIDER_WASI_VERSION=${PROVIDER_WASI_VERSION}" >> $GITHUB_ENV
echo "PROVIDER_VM_VERSION=${PROVIDER_VM_VERSION}" >> $GITHUB_ENV
- name: Build the docker containers
shell: bash
run: |
docker compose -f tests/docker/docker-compose.yml build \
--build-arg UBUNTU_VERSION=22.04 \
--build-arg YA_CORE_PROVIDER_VERSION=${PROVIDER_VERSION} \
--build-arg YA_CORE_REQUESTOR_VERSION=${REQUESTOR_VERSION} \
--build-arg YA_WASI_VERSION=${PROVIDER_WASI_VERSION} \
--build-arg YA_VM_VERSION=${PROVIDER_VM_VERSION}
- name: Start the docker containers
shell: bash
run: |
sudo service docker restart
docker compose -f tests/docker/docker-compose.yml down
docker compose -f tests/docker/docker-compose.yml up -d
- name: Fund the requestor
shell: bash
run: |
sleep 10
docker exec -t docker-requestor-1 /bin/sh -c "/golem-js/tests/docker/fundRequestor.sh"
- name: Install and build the SDK in the docker container
shell: bash
run: |
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run build && ./node_modules/.bin/cypress install && npm install --prefix examples && npm install ts-node"
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ jobs:
name: Build and unit-test on supported platforms and NodeJS versions
strategy:
matrix:
node-version: [18.x, 20.x]
# Make sure you're addressing it to the minor version, as sometimes macos was picking 20.9 while others 20.10
# and that caused issues with rollup
node-version: [18.19.x, 20.10.x]
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
Expand All @@ -34,7 +37,7 @@ jobs:

- name: Perform regular checks
run: |
npm install
npm ci
npm run format:check
npm run lint
npm run test:unit
Expand Down
118 changes: 57 additions & 61 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,24 @@ on:
permissions:
contents: read # for checkout

env:
PROVIDER_VERSION: ${{ github.event.inputs.provider_version || 'v0.13.2' }}
REQUESTOR_VERSION: ${{ github.event.inputs.requestor_version || 'v0.13.2' }}
PROVIDER_WASI_VERSION: ${{ github.event.inputs.provider_wasi_version || 'v0.2.2' }}
PROVIDER_VM_VERSION: ${{ github.event.inputs.provider_vm_version || 'v0.3.0' }}

jobs:
regular-checks:
name: Build and unit-test on supported platforms and NodeJS versions
strategy:
matrix:
node-version: [18.x, 20.x]
# Make sure you're addressing it to the minor version, as sometimes macos was picking 20.9 while others 20.10
# and that caused issues with rollup
node-version: [18.19.x, 20.10.x]
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
Expand All @@ -55,7 +64,7 @@ jobs:

- name: Perform regular checks
run: |
npm install
npm ci
npm run format:check
npm run lint
npm run test:unit
Expand All @@ -70,53 +79,15 @@ jobs:
name: unit-test-report
path: reports/unit-report.xml

run-integration-and-e2e-tests:
name: Run integration and E2E tests
run-e2e-tests:
name: Run E2E tests
needs: regular-checks
runs-on: goth2
env:
PROVIDER_VERSION: ${{ github.event.inputs.provider_version || 'v0.13.2' }}
REQUESTOR_VERSION: ${{ github.event.inputs.requestor_version || 'v0.13.2' }}
PROVIDER_WASI_VERSION: ${{ github.event.inputs.provider_wasi_version || 'v0.2.2' }}
PROVIDER_VM_VERSION: ${{ github.event.inputs.provider_vm_version || 'v0.3.0' }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use random string for subnet
# 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: echo "YAGNA_SUBNET=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '')" >> $GITHUB_ENV

- name: Set up Versions
run: |
echo "PROVIDER_VERSION=${PROVIDER_VERSION}" >> $GITHUB_ENV
echo "REQUESTOR_VERSION=${REQUESTOR_VERSION}" >> $GITHUB_ENV
echo "PROVIDER_WASI_VERSION=${PROVIDER_WASI_VERSION}" >> $GITHUB_ENV
echo "PROVIDER_VM_VERSION=${PROVIDER_VM_VERSION}" >> $GITHUB_ENV
- name: Build the docker containers
run: |
docker compose -f tests/docker/docker-compose.yml build \
--build-arg UBUNTU_VERSION=22.04 \
--build-arg YA_CORE_PROVIDER_VERSION=${PROVIDER_VERSION} \
--build-arg YA_CORE_REQUESTOR_VERSION=${REQUESTOR_VERSION} \
--build-arg YA_WASI_VERSION=${PROVIDER_WASI_VERSION} \
--build-arg YA_VM_VERSION=${PROVIDER_VM_VERSION}
- name: Start the docker containers
run: |
sudo service docker restart
docker compose -f tests/docker/docker-compose.yml down
docker compose -f tests/docker/docker-compose.yml up -d
- name: Fund the requestor
run: |
sleep 10
docker exec -t docker-requestor-1 /bin/sh -c "/golem-js/tests/docker/fundRequestor.sh"
- uses: actions/checkout@v3

- name: Install and build the SDK in the docker container
run: |
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run build && ./node_modules/.bin/cypress install && npm install --prefix examples && npm install ts-node"
- name: Prepare providers and requestor
uses: ./.github/actions/prepare-tests

- name: Start the E2E test
run: docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm run test:e2e"
Expand All @@ -128,17 +99,26 @@ jobs:
name: e2e-test-report
path: reports/e2e-report.xml

- name: Cleanup test environment
uses: ./.github/actions/cleanup-tests
with:
type: "e2e"

run-cypress-tests:
name: Run Cypress tests
needs: regular-checks
runs-on: goth2
steps:
- uses: actions/checkout@v3

- name: Prepare providers and requestor
uses: ./.github/actions/prepare-tests

- name: Run web server
run: |
docker exec -t -d docker-requestor-1 /bin/sh -c "cd /golem-js/examples/web && node app.mjs"
run: docker exec -t -d docker-requestor-1 /bin/sh -c "cd /golem-js/examples/web && node app.mjs"

- name: Run test suite
run: |
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm run test:cypress -- --browser chromium"
- name: Run the Examples tests
run: |
docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm run test:examples -- --exitOnError"
run: 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@v3
Expand All @@ -147,16 +127,32 @@ jobs:
name: cypress-logs
path: .cypress

- name: Cleanup Docker
if: always()
run: |
c=$(docker ps -q)
[[ $c ]] && docker kill $c
docker system prune -af
- name: Cleanup test environment
uses: ./.github/actions/cleanup-tests
with:
type: "cypress"

run-examples-tests:
name: Run Examples tests
needs: regular-checks
runs-on: goth2
steps:
- uses: actions/checkout@v3

- name: Prepare providers and requestor
uses: ./.github/actions/prepare-tests

- name: Run the Examples tests
run: docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm run test:examples -- --exitOnError"

- name: Cleanup test environment
uses: ./.github/actions/cleanup-tests
with:
type: "examples"

release:
name: Release the SDK to NPM and GitHub
needs: run-integration-and-e2e-tests
needs: [run-e2e-tests, run-cypress-tests, run-examples-tests]
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
Expand All @@ -173,7 +169,7 @@ jobs:
uses: actions/setup-node@v3
with:
# Semantic release requires this as bare minimum
node-version: 18
node-version: 20

- name: Install dependencies
run: npm install
Expand Down
Loading

0 comments on commit ddd84a0

Please sign in to comment.