Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADP-3224] Fix caching problems in GH workflows, add slack reporting #4272

Merged
merged 13 commits into from
Nov 30, 2023
34 changes: 28 additions & 6 deletions .github/workflows/docker_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ on:
schedule:
- cron: "0 23 * * *"
workflow_dispatch:
inputs:
network:
description: 'NETWORK'
required: true
default: 'mainnet'


jobs:
build:
Expand All @@ -27,4 +23,30 @@ jobs:
docker-compose up -d
./scripts/connect_wallet.rb
env:
NETWORK: ${{ github.event.inputs.network || 'mainnet' }}
NETWORK: preprod
report:
needs: [build]
if: always()
runs-on: ubuntu-latest
steps:
- name: Slack Notification on failure
if: needs.build.result == 'failure'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':poop:'
paolino marked this conversation as resolved.
Show resolved Hide resolved
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#FF0000'

- name: Slack Notification on success
if: needs.build.result == 'success'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':rocket:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#00FF00'
36 changes: 29 additions & 7 deletions .github/workflows/docker_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ on:
schedule:
- cron: "0 23 * * *"
workflow_dispatch:
inputs:
network:
description: 'NETWORK'
required: true
default: 'mainnet'


jobs:
build:
Expand All @@ -17,7 +13,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- uses: docker-practice/actions-setup-docker@1.0.11
- uses: docker-practice/actions-setup-docker@master
- uses: ruby/[email protected]
with:
ruby-version: 2.7.1
Expand All @@ -28,4 +24,30 @@ jobs:
docker-compose up -d
./scripts/connect_wallet.rb
env:
NETWORK: ${{ github.event.inputs.network || 'mainnet' }}
NETWORK: preprod
report:
needs: [build]
if: always()
runs-on: ubuntu-latest
steps:
- name: Slack Notification on failure
paolino marked this conversation as resolved.
Show resolved Hide resolved
if: needs.build.result == 'failure'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':poop:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#FF0000'

- name: Slack Notification on success
if: needs.build.result == 'success'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':rocket:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#00FF00'
103 changes: 70 additions & 33 deletions .github/workflows/e2e-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ on:
description: 'Wallet tag (docker)'
required: true
default: 'dev-master'
network:
description: 'Network'
required: true
default: 'preprod'
tags:
description: 'Test tags (all, light, offchain...)'
default: 'all'
Expand All @@ -30,6 +26,14 @@ jobs:

runs-on: ubuntu-latest

env:
TESTS_E2E_FIXTURES: ${{ secrets.TESTS_E2E_FIXTURES }}
BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_TOKEN_READ_BUILDS_ARTIFACTS }}
WALLET: ${{ github.event.inputs.walletTag || 'dev-master' }}
TESTS_E2E_TOKEN_METADATA: https://metadata.cardano-testnet.iohkdev.io/
TAGS: ${{ github.event.inputs.tags || 'all' }}
E2E_DOCKER_RUN: 1

steps:
- uses: actions/[email protected]

Expand All @@ -55,41 +59,47 @@ jobs:
run: bundle install

- name: ⚙️ Setup (get latest bins and configs and decode fixtures)
run: rake setup[$NETWORK]
run: rake setup[preprod]

- name: 🕒 Get Date/Time
id: date-time
shell: bash
run: |
echo "value=$(rake datetime)" >> $GITHUB_OUTPUT

- name: 💾 Cache node db
id: cache
id: cache-node
uses: actions/cache@v3
with:
path: test/e2e/state/node_db/${{ env.NETWORK }}
key: node-db-docker-${{ env.NETWORK }}-${{ steps.date-time.outputs.value }}
restore-keys: |
node-db-docker-${{ env.NETWORK }}-
node-db-Linux-${{ env.NETWORK }}-
path: test/e2e/state/node_db/preprod
key: node-db-docker-linux-preprod

- name: Fetch preprod snapshot
if: steps.cache-node.outputs.cache-hit != 'true'
run: |
cd state
mkdir node_db
cd node_db
mkdir preprod
cd preprod
curl -s https://downloads.csnapshots.io/snapshots/testnet/testnet-db-snapshot.json \
| jq -r .[].file_name > snapshot.json
curl -o - \
https://downloads.csnapshots.io/snapshots/testnet/$(cat snapshot.json) \
| lz4 -c -d - | tar -x -C .
mv db/* .

- name: 💾 Cache wallet db
id: cache-wallet
uses: actions/cache@v3
with:
path: test/e2e/state/wallet_db/${{ env.NETWORK }}
key: wallet-db3-${{ runner.os }}-${{ env.NETWORK }}-${{ steps.date-time.outputs.value }}
restore-keys: wallet-db3-docker-${{ env.NETWORK }}-
path: test/e2e/state/wallet_db/preprod
key: wallet-db-docker-linux-preprod

- name: 🚀 Start node and wallet
run: |
echo "Wallet: $WALLET"
echo "Node: ${{steps.cardano-node-tag.outputs.NODE_TAG}}"

NODE=${{steps.cardano-node-tag.outputs.NODE_TAG}} \
NODE_CONFIG_PATH=`pwd`/state/configs/$NETWORK \
DATA=`pwd`/state/node_db/$NETWORK \
WALLET_DATA=`pwd`/state/wallet_db/$NETWORK \
NODE_CONFIG_PATH=`pwd`/state/configs/preprod \
DATA=`pwd`/state/node_db/preprod \
WALLET_DATA=`pwd`/state/wallet_db/preprod \
docker-compose -f docker-compose-test.yml up --detach

- name: 🔍 Display versions
Expand All @@ -111,17 +121,44 @@ jobs:
uses: actions/upload-artifact@v3
if: always()
with:
name: ${{ runner.os }}-docker-logs
name: linux-docker-logs
path: test/e2e/state/logs

- name: Stop docker-compose
run: NODE_CONFIG_PATH=`pwd`/state/configs/$NETWORK docker-compose -f docker-compose-test.yml down
env:
TESTS_E2E_FIXTURES: ${{ secrets.TESTS_E2E_FIXTURES }}
BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_TOKEN_READ_BUILDS_ARTIFACTS }}
NETWORK: ${{ github.event.inputs.network || 'preprod' }}
WALLET: ${{ github.event.inputs.walletTag || 'dev-master' }}
TESTS_E2E_TOKEN_METADATA: https://metadata.cardano-testnet.iohkdev.io/
NODE_DB_CACHE: ${{ github.event.inputs.node_db_cache || 'GH' }}
TAGS: ${{ github.event.inputs.tags || 'all' }}
E2E_DOCKER_RUN: 1
run: NODE_CONFIG_PATH=`pwd`/state/configs/preprod docker-compose -f docker-compose-test.yml down

- name: 💾 GH Save Cache of node db
if: always()
uses: actions/cache/save@v3
with:
path: test/e2e/state/node_db/preprod
key: node-db-docker-linux-preprod

- name: 💾 GH Save Cache of wallet db
if: always()
uses: actions/cache/save@v3
with:
path: test/e2e/state/wallet_db/preprod
key: wallet-db-docker-linux-preprod

- name: Slack Notification on failure
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':poop:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#FF0000'

- name: Slack Notification on success
if: success()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':rocket:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#00FF00'
99 changes: 68 additions & 31 deletions .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ on:
- cron: "0 20 * * *"
workflow_dispatch:
inputs:
network:
description: 'Network'
required: true
default: 'preprod'

branch:
description: 'Run tests against branch'
default: 'master'
Expand All @@ -24,6 +21,12 @@ jobs:
test:
runs-on: ubuntu-latest

env:
TESTS_E2E_FIXTURES: ${{ secrets.TESTS_E2E_FIXTURES }}
BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_TOKEN_READ_BUILDS_ARTIFACTS }}
BRANCH: ${{ github.event.inputs.branch || '' }}
TAGS: ${{ github.event.inputs.tags || 'all' }}

steps:
- uses: actions/[email protected]

Expand All @@ -36,38 +39,44 @@ jobs:
- name: Install dependencies
run: bundle install

- name: 🕒 Get Date/Time
id: date-time
shell: bash
run: |
echo "value=$(rake datetime)" >> $GITHUB_OUTPUT

- name: 💾 GH Cache node db
id: cache
- name: 💾 GH Restore Cache of node db
id: cache-node
uses: actions/cache@v3
with:
path: test/e2e/state/node_db/${{ env.NETWORK }}
key: node-db-${{ runner.os }}-${{ env.NETWORK }}-${{ steps.date-time.outputs.value }}
restore-keys: |
node-db-${{ runner.os }}-${{ env.NETWORK }}-
path: test/e2e/state/node_db/preprod
key: node-db-e2e-linux-preprod

- name: 💾 Cache wallet db
id: cache-wallet
uses: actions/cache@v3
with:
path: test/e2e/state/wallet_db/${{ env.NETWORK }}
key: wallet-db3-${{ runner.os }}-${{ env.NETWORK }}-${{ steps.date-time.outputs.value }}
restore-keys: |
wallet-db3-${{ runner.os }}-${{ env.NETWORK }}-
path: test/e2e/state/wallet_db/preprod
key: wallet-db-e2e-linux-preprod

- name: Fetch preprod snapshot
if: steps.cache-node.outputs.cache-hit != 'true'
run: |
mkdir state
cd state
mkdir node_db
cd node_db
mkdir preprod
cd preprod
curl -s https://downloads.csnapshots.io/snapshots/testnet/testnet-db-snapshot.json \
| jq -r .[].file_name > snapshot.json
curl -o - \
https://downloads.csnapshots.io/snapshots/testnet/$(cat snapshot.json) \
| lz4 -c -d - | tar -x -C .
mv db/* .

- name: ⚙️ Setup (get latest bins and configs and decode fixtures)
run: rake setup[$NETWORK,$BRANCH]
run: rake setup[preprod,$BRANCH]

- name: 🔍 Display versions
run: rake display_versions

- name: 🚀 Start node and wallet
run: rake start_node_and_wallet[$NETWORK]
run: rake start_node_and_wallet[preprod]

- name: ⏳ Wait until node is synced
run: rake wait_until_node_synced
Expand All @@ -76,22 +85,50 @@ jobs:
run: rake spec SPEC_OPTS="-t $TAGS"

- name: 🏁 Stop node and wallet
run: rake stop_node_and_wallet[$NETWORK]
run: rake stop_node_and_wallet[preprod]

- name: 💾 GH Save Cache of node db
if: always()
uses: actions/cache/save@v3
with:
path: test/e2e/state/node_db/preprod
key: node-db-e2e-linux-preprod

- name: 💾 GH Save Cache of wallet db
if: always()
uses: actions/cache/save@v3
with:
path: test/e2e/state/wallet_db/preprod
key: wallet-db-e2e-linux-preprod

- name: 📎 Upload state
uses: actions/upload-artifact@v3
if: always()
with:
name: ${{ runner.os }}-state
name: linux-state
path: |
test/e2e/state/logs
test/e2e/state/configs
test/e2e/state/wallet_db

env:
TESTS_E2E_FIXTURES: ${{ secrets.TESTS_E2E_FIXTURES }}
BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_TOKEN_READ_BUILDS_ARTIFACTS }}
NETWORK: ${{ github.event.inputs.network || 'preprod' }}
BRANCH: ${{ github.event.inputs.branch || '' }}
NODE_DB_CACHE: ${{ github.event.inputs.node_db_cache || 'GH' }}
TAGS: ${{ github.event.inputs.tags || 'all' }}
- name: Slack Notification on failure
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':poop:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#FF0000'

- name: Slack Notification on success
if: success()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_ICON_EMOJI: ':rocket:'
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#00FF00'
Loading
Loading