-
Notifications
You must be signed in to change notification settings - Fork 39
121 lines (102 loc) · 4.36 KB
/
tests-dashmate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
on:
workflow_call:
inputs:
name:
type: string
description: Name
required: true
test-pattern:
type: string
description: Test pattern. i.e. test/e2e/*.spec.js
required: true
restore_local_network_data:
type: boolean
description: Load local network data from cache
default: false
jobs:
dashmate-test:
name: Run ${{ inputs.name }} tests
# TODO: Try with Github Runner, probably it will be the same time
runs-on: [ "self-hosted", "linux", "arm64", "ubuntu-platform" ]
timeout-minutes: 15
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure AWS credentials and bucket region
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Setup Node.JS
uses: ./.github/actions/nodejs
- name: Restore JS build artifacts
uses: strophy/actions-cache@opendal-update
with:
bucket: multi-runner-cache-x1xibo9c
root: actions-cache
path: build-js-artifacts-${{ github.sha }}.tar
key: build-js-artifacts/${{ github.sha }}
- name: Unpack JS build artifacts archive
run: tar -xvf build-js-artifacts-${{ github.sha }}.tar
- name: Replace with pre-built images
run: |
set -x
# Login to ECR
DOCKER_HUB_ORG="${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com"
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin $DOCKER_HUB_ORG
SHA_TAG=sha-${{ github.sha }}
# Drive
DRIVE_IMAGE_AND_VERSION=$(yarn dashmate config get --config=local platform.drive.abci.docker.image)
docker pull $DOCKER_HUB_ORG/drive:$SHA_TAG
docker tag $DOCKER_HUB_ORG/drive:$SHA_TAG $DRIVE_IMAGE_AND_VERSION
# DAPI
DAPI_IMAGE_AND_VERSION=$(yarn dashmate config get --config=local platform.dapi.api.docker.image)
docker pull $DOCKER_HUB_ORG/dapi:$SHA_TAG
docker tag $DOCKER_HUB_ORG/dapi:$SHA_TAG $DAPI_IMAGE_AND_VERSION
# Dashmate helper image is hardcoded so we replace it with the built one
VERSION=$(cat package.json | jq -r '.version')
docker pull $DOCKER_HUB_ORG/dashmate-helper:$SHA_TAG
docker tag $DOCKER_HUB_ORG/dashmate-helper:$SHA_TAG dashpay/dashmate-helper:${VERSION}
shell: bash
- name: Get dashmate fingerprint
id: dashmate-fingerprint
run: echo "sha=$(git log -1 --format="%h" -- packages/dashmate)" >> $GITHUB_OUTPUT
if: inputs.restore_local_network_data == true
- name: Use test suite local network data to speed up dashmate local network tests
id: local-network-data
uses: strophy/actions-cache/restore@opendal-update
with:
bucket: multi-runner-cache-x1xibo9c
root: local-network-data
path: |
/home/ubuntu/.dashmate
dashmate_volumes_dump
key: local-network-volumes/${{ steps.dashmate-fingerprint.outputs.sha }}
if: inputs.restore_local_network_data == true
- name: Restore dashmate volumes
run: ./scripts/dashmate/volumes/restore.sh
if: steps.local-network-data.outputs.cache-hit == 'true'
- name: Run tests with cache
run: yarn workspace dashmate run mocha ${{ inputs.test-pattern }}
env:
DEBUG: 1
DASHMATE_E2E_TESTS_SKIP_IMAGE_BUILD: true
DASHMATE_E2E_TESTS_LOCAL_HOMEDIR: /home/ubuntu/.dashmate
if: steps.local-network-data.outputs.cache-hit == 'true'
- name: Run tests without cache
run: yarn workspace dashmate run mocha ${{ inputs.test-pattern }}
env:
DEBUG: 1
DASHMATE_E2E_TESTS_SKIP_IMAGE_BUILD: true
if: steps.local-network-data.outputs.cache-hit != 'true'
- name: Show Docker logs
if: ${{ failure() }}
uses: jwalton/gh-docker-logs@v2