[DebugAdapter] Add some unit tests #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Release | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| lib-build-and-test: | |
| name: Build & Test | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| strategy: | |
| # ensures each build runs even if one fails | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: log2src | |
| asset_name: log2src-${{ github.ref_name }}-linux-x64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: log2src | |
| asset_name: log2src-${{ github.ref_name }}-macos-x64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: log2src | |
| asset_name: log2src-${{ github.ref_name }}-macos-arm64 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: log2src.exe | |
| asset_name: log2src-${{ github.ref_name }}-windows-x64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| override: true | |
| - name: Setup cross-compilation for ARM64 | |
| if: matrix.target == 'aarch64-apple-darwin' | |
| run: rustup target add aarch64-apple-darwin | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Build release binary for extension tests (macOS ARM64 only) | |
| if: matrix.target == 'aarch64-apple-darwin' | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Upload release binary for extension tests (macOS ARM64 only) | |
| if: matrix.target == 'aarch64-apple-darwin' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: log2src-test-binary | |
| path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| if-no-files-found: error | |
| vscode-extension-test: | |
| name: Test VS Code Extension | |
| needs: [lib-build-and-test] | |
| runs-on: macos-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download log2src binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: log2src-test-binary | |
| path: downloaded-binary | |
| - name: Setup binary for VS Code extension | |
| run: | | |
| mkdir -p editors/code/bin/darwin-arm64 | |
| cp downloaded-binary/log2src editors/code/bin/darwin-arm64/ | |
| chmod +x editors/code/bin/darwin-arm64/log2src | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.8.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'editors/code/pnpm-lock.yaml' | |
| - name: Install Dependencies | |
| working-directory: editors/code | |
| run: pnpm install | |
| - name: Run tests | |
| working-directory: editors/code | |
| run: pnpm run test | |
| build-release: | |
| name: Build Release | |
| needs: [lib-build-and-test] | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| strategy: | |
| # ensures each build runs even if one fails | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: log2src | |
| asset_name: log2src-${{ github.ref_name }}-linux-x64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: log2src | |
| asset_name: log2src-${{ github.ref_name }}-macos-x64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: log2src | |
| asset_name: log2src-${{ github.ref_name }}-macos-arm64 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: log2src.exe | |
| asset_name: log2src-${{ github.ref_name }}-windows-x64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| override: true | |
| - name: Setup cross-compilation for ARM64 | |
| if: matrix.target == 'aarch64-apple-darwin' | |
| run: rustup target add aarch64-apple-darwin | |
| - name: Build release binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package binary (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| mkdir -p release | |
| cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/ | |
| cd release && tar -czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }} | |
| - name: Package binary (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| mkdir -p release | |
| copy target\${{ matrix.target }}\release\${{ matrix.artifact_name }} release\ | |
| cd release && 7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: release/${{ matrix.asset_name }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} | |
| if-no-files-found: error | |
| vscode-extension: | |
| name: Build VS Code Extensions | |
| needs: [build-release] | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.8.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'editors/code/pnpm-lock.yaml' | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Extract binaries for VS Code extension | |
| run: | | |
| mkdir -p editors/code/bin/{linux-x64,darwin-x64,darwin-arm64,win32-x64} | |
| tar -xzf artifacts/log2src-${{ github.ref_name }}-linux-x64/log2src-${{ github.ref_name }}-linux-x64.tar.gz -C editors/code/bin/linux-x64 | |
| tar -xzf artifacts/log2src-${{ github.ref_name }}-macos-x64/log2src-${{ github.ref_name }}-macos-x64.tar.gz -C editors/code/bin/darwin-x64 | |
| tar -xzf artifacts/log2src-${{ github.ref_name }}-macos-arm64/log2src-${{ github.ref_name }}-macos-arm64.tar.gz -C editors/code/bin/darwin-arm64 | |
| unzip -o artifacts/log2src-${{ github.ref_name }}-windows-x64/log2src-${{ github.ref_name }}-windows-x64.zip -d editors/code/bin/win-x64 | |
| - name: Install Dependencies | |
| working-directory: editors/code | |
| run: pnpm install | |
| - name: Run tests (Linux) | |
| working-directory: editors/code | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get install -y xvfb | |
| pnpm run test:ci | |
| - name: Run Tests (Osx/Windows) | |
| working-directory: editors/code | |
| if: runner.os != 'Linux' | |
| run: pnpm run test | |
| - name: Build VS Code extension | |
| if: startsWith(github.ref, 'refs/tags/') | |
| working-directory: editors/code | |
| run: | | |
| REF_NAME="${{ github.ref_name }}" | |
| VERSION=${REF_NAME#v} | |
| # Update version in package.json | |
| jq '.version = "'$VERSION'"' package.json > package.json.new | |
| mv package.json.new package.json | |
| pnpm vsce package --no-dependencies | |
| - name: Upload VS Code extension | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: log2src-ext-${{ github.ref_name }}.vsix | |
| path: editors/code/log2src-ext-*.vsix | |
| if-no-files-found: error | |
| release: | |
| name: Create Release | |
| needs: [build-release, vscode-extension] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release | |
| - name: List files | |
| run: ls -R release | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: log2src ${{ github.ref_name }} | |
| token: ${{ secrets.L2S_RELEASE }} | |
| files: release/**/* | |
| draft: true | |
| prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }} |