Skip to content

Commit

Permalink
chore(github): update the observe action to share logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Jul 16, 2024
1 parent 82e3bbc commit 19f5078
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/observe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ jobs:
run: yarn

- name: Observe
run: yarn observe
run: |
node tools/observe.js --silent > output.log 2>&1 || exit 1
continue-on-error: true

- name: Read observation results
id: read-log
run: echo "::set-output name=log::$(cat output.log)"

# Failure notification
- name: Send Slack failure notification
if: failure()
env:
SLACK_TITLE: IO/AO Contract Observation failed!
SLACK_COLOR: danger
SLACK_MESSAGE: 'Observation failed! Logs: ${{ steps.read-log.outputs.log }}'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: rtCamp/action-slack-notify@v2

Expand All @@ -40,5 +46,6 @@ jobs:
env:
SLACK_TITLE: IO/AO Contract Observation succeeded!
SLACK_COLOR: good
SLACK_MESSAGE: 'Observation succeeded! Logs: ${{ steps.read-log.outputs.log }}'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: rtCamp/action-slack-notify@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ luacov-html
*.gz
dist
luacov.stats.out
*.log
11 changes: 4 additions & 7 deletions tools/observe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { IOToken, IO, mIOToken } = require('@ar.io/sdk');

const ioContract = IO.init();
const assert = require('node:assert');

Expand Down Expand Up @@ -27,11 +26,9 @@ const assert = require('node:assert');
totalDifference,
);

console.log('Total distributed rewards for last epoch: ', {
epochIndex: lastEpochDistribution.epochIndex,
totalDistributedRewards:
lastEpochDistribution.distributions.totalDistributedRewards,
});
console.log(
`\n:moneybag: Total distributed rewards for last epoch: ${new mIOToken(lastEpochDistribution.distributions.totalDistributedRewards)} IO`,
);

// get the total supply
const totalSupply = await ioContract.getTokenSupply();
Expand All @@ -44,7 +41,7 @@ const assert = require('node:assert');
totalSupply,
);
console.log(
`Total token supply: ${new mIOToken(totalSupply).toIO().valueOf()} IO`,
`\n:white_check_mark: Total token supply: ${new mIOToken(totalSupply).toIO().valueOf()} IO`,
);
} catch (error) {
console.error('Assertion failed:', error.message);
Expand Down

0 comments on commit 19f5078

Please sign in to comment.