Skip to content

Commit

Permalink
feat: use custom grading actions v2
Browse files Browse the repository at this point in the history
Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use latest version of grader

Signed-off-by: Anmol Sharma <[email protected]>

feat: use custome grader action

Signed-off-by: Anmol Sharma <[email protected]>
  • Loading branch information
theanmolsharma committed Mar 19, 2024
1 parent d7ea7a0 commit b61a611
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/classroom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Autograding Tests
'on':
- push
- workflow_dispatch
- repository_dispatch
permissions:
checks: write
actions: read
contents: read
jobs:
run-autograding-tests:
runs-on: ubuntu-latest
if: github.actor != 'github-classroom[bot]'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: 'Validate block '
id: validate-block
uses: SummerOfBitcoin/code-challenge-2024-grader@v2
with:
test-name: 'Validate block '
setup-command: chmod +x ./run.sh && ./run.sh
command: chmod +x ./test.sh && ./test.sh
timeout: 10
max-fee: 20616923
max-score: 100
- name: Autograding Reporter
uses: SummerOfBitcoin/autograding-grading-reporter@v2
env:
VALIDATE-BLOCK_RESULTS: "${{steps.validate-block.outputs.result}}"
with:
runners: validate-block
7 changes: 5 additions & 2 deletions grader/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {readFileSync} from 'fs';
import {readFileSync, writeFileSync} from 'fs';
import {validateHeader} from "./validate-header.js";
import {validateBlock} from "./validate-block.js";

Expand All @@ -18,7 +18,10 @@ export const run = async () => {
await validateHeader(header, txids);

// Validate the block
validateBlock(coinbase, txids);
const result = validateBlock(coinbase, txids);

// Write the result to a file
writeFileSync('../result.json', JSON.stringify(result, null, 2));
} catch (error) {
console.log(error.message);
throw error;
Expand Down
4 changes: 4 additions & 0 deletions grader/src/validate-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ export const validateBlock = (coinbase, txids) => {
}

console.log(`Congratulations! Block is valid with a total fee of ${totalFee} sats and a total weight of ${totalWeight}!`);
return {
fee: totalFee.toString(),
weight: totalWeight.toString(),
}
}

0 comments on commit b61a611

Please sign in to comment.