Unify workflows #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- labeled | |
concurrency: | |
group: build | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
services: | |
# required by unit tests | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
# set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: hoprnet/hopr-workflows/actions/setup-node-js@master | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Building | |
run: yarn build | |
- name: Linting | |
run: yarn lint:ci | |
- name: Formatting | |
run: yarn format:ci | |
- name: Review dependencies | |
# TODO: update ethers to v6 in RPCh SDK to remove the ignore-path | |
run: yarn depcheck --ignore-path="examples" | |
- name: Testing | |
run: yarn test | |
env: | |
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres | |
# - name: Run E2E tests | |
# run: yarn test:e2e | |
publish: | |
name: Publish | |
runs-on: self-hosted-hoprnet-small | |
needs: build | |
strategy: | |
matrix: | |
project: | |
- discovery-platform | |
- rpc-server | |
- availability-monitor | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup GCP | |
id: gcp | |
uses: hoprnet/hopr-workflows/actions/setup-gcp@master | |
with: | |
google-credentials: ${{ secrets.GOOGLE_HOPRASSOCIATION_CREDENTIALS_REGISTRY }} | |
login-artifact-registry: 'true' | |
install-sdk: 'true' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: kubernetes | |
- name: Get PR version | |
id: variables | |
run: | | |
PR_VERSION=$(jq -r '.version' apps/"${{ matrix.project }}"/package.json)-pr."${{ github.event.pull_request.number }}" | |
echo "PR_VERSION=${PR_VERSION}" >> $GITHUB_OUTPUT | |
- name: Build and push docker image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
file: "./apps/${{ matrix.project }}/Dockerfile" | |
tags: ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ matrix.project }}:${{ steps.variables.outputs.PR_VERSION }} | |
- name: Tag staging | |
if: contains(github.event.pull_request.labels.*.name, 'deploy_staging') || github.event.label.name == 'deploy_staging' && github.event.action == 'labeled' | |
run: | | |
gcloud artifacts docker tags add ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ matrix.project }}:${{ steps.variables.outputs.PR_VERSION }} ${{ vars.DOCKER_IMAGE_REGISTRY }}/${{ matrix.project }}:staging | |
deploy: | |
name: Deploy | |
needs: publish | |
if: contains(github.event.pull_request.labels.*.name, 'deploy_staging') || github.event.label.name == 'deploy_staging' && github.event.action == 'labeled' | |
uses: ./.github/workflows/deploy.yaml | |
with: | |
branch: ${{ github.event.pull_request.head.ref }} | |
secrets: inherit |