Skip to content

Commit

Permalink
setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaviderb committed Dec 26, 2023
1 parent ec97115 commit 15c3bcc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Solana Program Tests

on: [push]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Rust
uses: hecrj/setup-rust-action@v2
with:
rust-version: stable

- name: Setup Solana Tool suite
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.17.13/install)"
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '18.x'

- name: Run Tests
run: |
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
solana-keygen new --no-passphrase --force -o program.json
cd e2e
npm install
npm run test



3 changes: 2 additions & 1 deletion e2e/down.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ interface Global {
module.exports = async function() {
const gb = global as Global;

console.log('Killing Solana Validator...');
// Kill Solana Validator
if (gb.SOLANA_VALIDATOR_PROCESS && gb.SOLANA_VALIDATOR_PROCESS.kill()) {
process.exit(1);
process.exit(0);
}
}
4 changes: 1 addition & 3 deletions e2e/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ module.exports = async function() {
});

// Wait for RPC to be ready

await waitForRpc();

// if Solana validator is ready, start logging

spawn('solana', ["logs"])
.stdout.on('data', (data: Buffer) => {
if (!fs.existsSync('./program.log')) {
Expand All @@ -56,7 +54,7 @@ async function waitForRpc(): Promise<boolean> {
}

async function validateRpc(): Promise<boolean> {
const data = await fetch(`http://localhost:${RPC_PORT}`, {
const data = await fetch(`http://127.0.0.1:${RPC_PORT}`, {
method: 'post',
body: JSON.stringify({
jsonrpc: "2.0",
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/counter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Counter Program', () => {
const programId = new PublicKey(process.env['SOLANA_PROGRAM_ID'] as string);
const wallet = Keypair.generate();
const port = process.env['RPC_PORT'];
const connection = new Connection(`http://localhost:${port}`, 'confirmed');
const connection = new Connection(`http://127.0.0.1:${port}`, 'confirmed');


test('Initialize Counter', async () => {
Expand Down

0 comments on commit 15c3bcc

Please sign in to comment.