-
Notifications
You must be signed in to change notification settings - Fork 39
117 lines (99 loc) · 3.94 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
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
runs-on: ubuntu-24.04
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: Login to ECR
uses: ./.github/actions/aws_ecr_login
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ vars.AWS_REGION }}
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
- name: Setup Node.JS
uses: ./.github/actions/nodejs
- name: Download JS build artifacts
uses: actions/download-artifact@v4
with:
name: js-build-${{ github.sha }}
path: packages
- name: Replace with pre-built images
run: |
set -e
# Login to ECR
DOCKER_HUB_ORG="${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com"
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: Set HOME variable to github context
shell: bash
run: echo "HOME=$HOME" >> $GITHUB_ENV
- name: Restore test suite local network data to speed up dashmate local network tests
id: local-network-data
uses: actions/cache/restore@v4
with:
path: |
${{ env.HOME }}/.dashmate
**/.env
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: ${{ env.HOME }}/.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 == 'false'
- name: Show Docker logs
if: ${{ failure() }}
uses: jwalton/gh-docker-logs@v2