Skip to content

Test VSCode Extension #5

Test VSCode Extension

Test VSCode Extension #5

name: Test VSCode Extension
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18.x, 20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Compile extension
run: npm run compile
- name: Package extension
run: npm run package
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Package VSIX
run: vsce package --no-dependencies
- name: Setup test environment
run: |
mkdir -p test-workspace
cd test-workspace
npm init -y
- name: Create sample Solidity files
run: |
cat > test-workspace/SimpleStorage.sol << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 public storedData;
event DataStored(uint256 data);
function set(uint256 x) public {
storedData = x;
emit DataStored(x);
}
function get() public view returns (uint256) {
return storedData;
}
function increment() public {
storedData = storedData + 1;
}
}
EOF
cat > test-workspace/Token.sol << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Token {
mapping(address => uint256) public balances;
uint256 public totalSupply;
event Transfer(address indexed from, address indexed to, uint256 value);
constructor(uint256 _initialSupply) {
totalSupply = _initialSupply;
balances[msg.sender] = _initialSupply;
}
function transfer(address to, uint256 amount) public returns (bool) {
require(balances[msg.sender] >= amount, "Insufficient balance");
balances[msg.sender] -= amount;
balances[to] += amount;
emit Transfer(msg.sender, to, amount);
return true;
}
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
}
EOF
- name: Run extension tests
run: |
npm run test:integration
npm run test:chunking
npm run test:lsp
env:
CI: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-node${{ matrix.node-version }}
path: |
test-workspace/traverse-output/
*.vsix
integration-test:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm ci
- name: Run integration tests
run: |
npm run compile
node test/run-integration-tests.js
env:
CI: true