Use workflow_call to run tests/publish build snapshot and add E2E (#175)

* Add workflow_call

* Add missing import secrest

* Run e2e with aqua-playground (#179)

* Try to run e2e with aqua-playground

* Use workflow_call to run local tests and publish snapshot

* Run e2e and tests in parallel

* Colors!

* Always add comment

* Use master branch of aqua-playground

* Remove invalid `cache` key

* Update .github/workflows/run-tests.yml

* Fix branch name in version
This commit is contained in:
Anatoly Laskaris 2022-09-06 17:51:43 +03:00 committed by GitHub
parent e167cf9eca
commit b68d61068a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 221 additions and 125 deletions

View File

@ -1,73 +0,0 @@
name: "Publish development branch packages"
on:
push:
jobs:
publish-branch:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: "Setup node with self-hosted npm registry"
uses: actions/setup-node@v2
with:
node-version: "16"
registry-url: "https://npm.fluence.dev"
- name: "Build packages"
run: |
pnpm i
pnpm -r build
- name: "Import secrets"
uses: hashicorp/vault-action@v2.4.2
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
- name: "Generate package version"
id: version
run: |
BRANCH=${GITHUB_REF#refs/heads/}
SHA=$(git rev-parse --short HEAD)
echo "::set-output name=sha::$SHA"
echo "::set-output name=branch::${BRANCH//[^a-zA-Z0-9-]/-}"
- name: "Set package version"
env:
BRANCH: ${{ steps.version.outputs.branch }}
SHA: ${{ steps.version.outputs.sha }}
RUN: ${{ github.run_number }}
ATTEMPT: ${{ github.run_attempt }}
run: node ci.js bump-version ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}
- name: "Publish to self-hosted npm repo"
run: pnpm --no-git-checks --registry https://npm.fluence.dev -r publish --tag snapshot -filter '@fluencelabs/*'
- name: "Click to see published version"
run: |
fjs_version=$(node ci.js get-version)
echo "FluenceJS version is ${fjs_version}"
echo "To install it run the following: "
echo ""
echo "echo '@fluencelabs:registry=https://npm.fluence.dev/' > .npmrc"
echo "npm i @fluencelabs/fluence@${fjs_version}"

25
.github/workflows/run-tests.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Run tests
on:
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
fluence-js:
uses: ./.github/workflows/tests.yml
with:
ref: ${{ github.ref }}
snapshot:
uses: ./.github/workflows/snapshot.yml
aqua-playground:
needs: snapshot
uses: fluencelabs/aqua-playground/.github/workflows/tests.yml@master
with:
fluence-js-version: ${{ needs.snapshot.outputs.fluence-js-version }}

View File

@ -1,52 +0,0 @@
name: Run tests
on:
push:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 17.x]
env:
RUST_PEER_IMAGE: fluencelabs/fluence
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Setup docker-compose
uses: KengoTODA/actions-setup-docker-compose@v1.0.9
with:
version: 'v2.10.0'
- name: Pull image
run: docker pull ${RUST_PEER_IMAGE}
- name: Run rust-peer
uses: isbang/compose-action@v1.1.0
with:
compose-file: ".github/e2e/docker-compose.yml"
down-flags: "--volumes"
- name: Install deps
run: pnpm i
- name: Run tests
run: |
pnpm -r build
pnpm -r test
env:
CI: true

109
.github/workflows/snapshot.yml vendored Normal file
View File

@ -0,0 +1,109 @@
name: Publish snapshot
on:
workflow_call:
outputs:
fluence-js-version:
description: "FluenceJS snapshot version"
value: ${{ jobs.publish-snapshot.outputs.fluence-js-version }}
env:
FORCE_COLOR: true
CI: true
jobs:
publish-snapshot:
name: "Publish snapshot"
runs-on: ubuntu-latest
outputs:
fluence-js-version: "${{ steps.build.outputs.version }}"
permissions:
contents: read
id-token: write
steps:
- name: Checkout fluence-js
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Setup node with self-hosted npm registry
uses: actions/setup-node@v2
with:
node-version: "16"
registry-url: "https://npm.fluence.dev"
- run: pnpm i
- run: pnpm -r build
- name: Import secrets
uses: hashicorp/vault-action@v2.4.2
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN
- name: Generate package version
id: version
run: |
SHA=$(git rev-parse --short HEAD)
echo "::set-output name=sha::$SHA"
echo "::set-output name=branch::${GITHUB_HEAD_REF//[^a-zA-Z0-9-]/-}"
- name: Set package version
id: build
env:
BRANCH: ${{ steps.version.outputs.branch }}
SHA: ${{ steps.version.outputs.sha }}
RUN: ${{ github.run_number }}
ATTEMPT: ${{ github.run_attempt }}
run: |
node ci.js bump-version ${{ env.BRANCH }}-${{ env.SHA }}-${{ env.RUN }}-${{ env.ATTEMPT }}
echo "::set-output name=version::$(node ci.js get-version)"
- name: Publish to self-hosted npm repo
run: pnpm --no-git-checks --registry https://npm.fluence.dev -r publish --tag e2e -filter '@fluencelabs/*'
comment:
name: "Update comment"
runs-on: ubuntu-latest
needs:
- publish-snapshot
env:
FLUENCE_JS_VERSION: ${{ needs.publish-snapshot.outputs.fluence-js-version }}
steps:
- name: Find comment
uses: peter-evans/find-comment@v1
id: comment
with:
issue-number: "${{ github.event.pull_request.number }}"
comment-author: github-actions[bot]
body-includes: "## FluenceJS version is"
- name: Update comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
issue-number: "${{ github.event.pull_request.number }}"
edit-mode: replace
body: |
## FluenceJS version is [${{ env.FLUENCE_JS_VERSION }}](https://npm.fluence.dev/-/web/detail/@fluencelabs/fluence/v/${{ env.FLUENCE_JS_VERSION }})
To install it run:
```shell
npm login --registry https://npm.fluence.dev
npm i @fluencelabs/fluence@${{ env.FLUENCE_JS_VERSION }} --registry=https://npm.fluence.dev
```

87
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: Run tests with worflow_call
on:
workflow_call:
inputs:
rust-peer-image:
description: "rust-peer image tag"
type: string
default: "fluencelabs/fluence:minimal"
ref:
type: string
default: "master"
env:
RUST_PEER_IMAGE: "${{ inputs.rust-peer-image }}"
FORCE_COLOR: true
CI: true
jobs:
fluence-js:
name: "Run tests"
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
matrix:
node-version:
- 16.x
- 17.x
steps:
- name: Import secrets
uses: hashicorp/vault-action@v2.4.1
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
secrets: |
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: docker.fluence.dev
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Checkout
uses: actions/checkout@v3
with:
repository: fluencelabs/fluence-js
ref: ${{ inputs.ref }}
- name: Setup docker-compose
uses: KengoTODA/actions-setup-docker-compose@v1.0.9
with:
version: 'v2.10.0'
- name: Pull rust-peer image
run: docker pull $RUST_PEER_IMAGE
- name: Run rust-peer
uses: isbang/compose-action@v1.1.0
with:
compose-file: ".github/e2e/docker-compose.yml"
down-flags: "--volumes"
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: pnpm i
- run: pnpm -r build
- run: pnpm -r test