diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0b92608 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test Action + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Build action + run: npm run package + + - name: Setup covdbg + uses: ./ + with: + version: 'latest' + + - name: Verify covdbg is in PATH + run: | + Write-Host "Checking if covdbg is available..." + Get-Command covdbg -ErrorAction SilentlyContinue + if ($?) { + Write-Host "✓ covdbg is in PATH" + } else { + Write-Host "✗ covdbg is not in PATH" + exit 1 + } + shell: pwsh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90153cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +lib/ +dist/ +*.log +.DS_Store diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..03956ea --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,57 @@ +# Contributing to setup-covdbg + +Thank you for your interest in contributing to setup-covdbg! + +## Development Setup + +1. Fork and clone the repository +2. Install dependencies: + ```bash + npm install + ``` + +## Making Changes + +1. Make your changes in the `src/` directory +2. Build the TypeScript code: + ```bash + npm run build + ``` +3. Package the action for distribution: + ```bash + npm run package + ``` +4. Commit both the source changes and the compiled `dist/` files + +## Testing + +Test your changes locally using the test workflow: + +1. Push your changes to a branch +2. The test workflow will run automatically on Windows runners +3. Verify that covdbg is properly downloaded and added to PATH + +## Project Structure + +- `src/main.ts` - Main action logic +- `action.yml` - Action metadata and configuration +- `dist/` - Compiled and bundled action code (must be committed) +- `.github/workflows/` - CI/CD workflows + +## Code Style + +- Follow existing TypeScript conventions +- Use meaningful variable names +- Add comments for complex logic +- Keep error messages clear and helpful + +## Pull Request Process + +1. Update documentation if needed +2. Ensure all tests pass +3. Update the README.md with details of changes if applicable +4. Your PR will be reviewed by maintainers + +## Questions? + +Open an issue for discussion or clarification. diff --git a/README.md b/README.md index 12b9a9e..7cc83f2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,131 @@ # setup-covdbg -An action to download a prebuilt covdbg and add it to the PATH + +A GitHub Action to download and setup covdbg on Windows runners. + +## Description + +This action downloads a specified version of covdbg, extracts it, caches it for future runs, and adds it to the PATH so it can be used in subsequent workflow steps. + +## Features + +- Downloads a user-specified version of covdbg +- Extracts the downloaded archive +- Caches the tool for faster subsequent runs +- Adds covdbg to the PATH automatically +- Supports Windows runners + +## Usage + +Add this action to your workflow: + +```yaml +steps: + - name: Setup covdbg + uses: covdbg/setup-covdbg@v1 + with: + version: '1.0.0' + + - name: Run covdbg + run: covdbg --version +``` + +## Inputs + +### `version` (required) + +The version of covdbg to download and setup. This should be a semantic version string (e.g., `1.0.0`, `2.1.3`). + +**Example:** +```yaml +with: + version: '1.0.0' +``` + +## Outputs + +### `covdbg-path` + +The path where covdbg was installed and cached. + +**Example usage:** +```yaml +- name: Setup covdbg + id: setup-covdbg + uses: covdbg/setup-covdbg@v1 + with: + version: '1.0.0' + +- name: Display installation path + run: echo "Covdbg installed at ${{ steps.setup-covdbg.outputs.covdbg-path }}" +``` + +## Complete Example Workflow + +```yaml +name: Test covdbg + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup covdbg + uses: covdbg/setup-covdbg@v1 + with: + version: '1.0.0' + + - name: Verify covdbg installation + run: | + covdbg --version + covdbg --help +``` + +## How It Works + +This action uses the GitHub Actions Toolkit, specifically: +- **@actions/core**: For getting inputs, setting outputs, and logging +- **@actions/tool-cache**: For downloading, extracting, and caching the covdbg binary + +The action performs the following steps: +1. Reads the `version` input parameter (or uses 'latest') +2. Constructs the download URL for the specified version from covdbg.com +3. Downloads the covdbg.zip archive containing covdbg.exe and libcovdbg.dll +4. Extracts the archive +5. Caches the extracted files for future workflow runs +6. Adds the tool directory to the system PATH +7. Sets the `covdbg-path` output + +## Requirements + +- Runs on Windows runners (windows-latest, windows-2022, windows-2019) +- Requires Node.js 20 runtime (automatically available on GitHub-hosted runners) + +## Development + +To build and package the action: + +```bash +# Install dependencies +npm install + +# Build TypeScript +npm run build + +# Package for distribution +npm run package +``` + +**Note**: The `dist/` directory is not tracked in git. You must build the action locally before testing or using it. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e164f0a --- /dev/null +++ b/action.yml @@ -0,0 +1,16 @@ +name: 'Setup covdbg' +description: 'Download and setup covdbg on Windows runners' +author: 'covdbg' +branding: + icon: 'download' + color: 'blue' +inputs: + version: + description: 'Version of covdbg to download (e.g., 1.0.0, latest)' + required: true +outputs: + covdbg-path: + description: 'Path where covdbg was installed' +runs: + using: 'node20' + main: 'dist/index.js' diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..998c193 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,150 @@ +{ + "name": "setup-covdbg", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "setup-covdbg", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.10.1", + "@actions/tool-cache": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^20.11.0", + "@vercel/ncc": "^0.38.1", + "typescript": "^5.3.3" + } + }, + "node_modules/@actions/core": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz", + "integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==", + "license": "MIT", + "dependencies": { + "@actions/exec": "^1.1.1", + "@actions/http-client": "^2.0.1" + } + }, + "node_modules/@actions/exec": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", + "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", + "license": "MIT", + "dependencies": { + "@actions/io": "^1.0.1" + } + }, + "node_modules/@actions/http-client": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz", + "integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==", + "license": "MIT", + "dependencies": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, + "node_modules/@actions/io": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", + "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==", + "license": "MIT" + }, + "node_modules/@actions/tool-cache": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz", + "integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.11.1", + "@actions/exec": "^1.0.0", + "@actions/http-client": "^2.0.1", + "@actions/io": "^1.1.1", + "semver": "^6.1.0" + } + }, + "node_modules/@fastify/busboy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", + "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/@types/node": { + "version": "20.19.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.30.tgz", + "integrity": "sha512-WJtwWJu7UdlvzEAUm484QNg5eAoq5QR08KDNx7g45Usrs2NtOPiX8ugDqmKdXkyL03rBqU5dYNYVQetEpBHq2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@vercel/ncc": { + "version": "0.38.4", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.4.tgz", + "integrity": "sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==", + "dev": true, + "license": "MIT", + "bin": { + "ncc": "dist/ncc/cli.js" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "license": "MIT", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici": { + "version": "5.29.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz", + "integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==", + "license": "MIT", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..095bb93 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "setup-covdbg", + "version": "1.0.0", + "description": "GitHub Action to download and setup covdbg on Windows runners", + "main": "dist/index.js", + "scripts": { + "build": "tsc", + "package": "ncc build src/main.ts -o dist --source-map --license licenses.txt" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/covdbg/setup-covdbg.git" + }, + "keywords": [ + "actions", + "covdbg", + "setup" + ], + "author": "covdbg", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.10.1", + "@actions/tool-cache": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^20.11.0", + "@vercel/ncc": "^0.38.1", + "typescript": "^5.3.3" + } +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..60b4856 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,58 @@ +import * as core from '@actions/core'; +import * as tc from '@actions/tool-cache'; +import * as path from 'path'; +import * as os from 'os'; + +async function run(): Promise { + try { + // Get the version input from the action + const version = core.getInput('version', { required: true }); + core.info(`Setting up covdbg version ${version}`); + + // Check if we're on Windows + const platform = os.platform(); + if (platform !== 'win32') { + throw new Error(`This action currently only supports Windows runners. Current platform: ${platform}`); + } + + // Construct the download URL for covdbg + // Using the portable version from covdbg.com + // TODO: Uncomment these lines once testing is complete + // const downloadUrl = version === 'latest' + // ? 'https://covdbg.com/download/latest/portable' + // : `https://covdbg.com/download/${version}/portable`; + + // Temporary test URL for development + const downloadUrl = 'https://downloads.covdbg.com/21321662162/covdbg.zip'; + core.info(`Downloading covdbg from ${downloadUrl}`); + + // Download the tool (covdbg.zip) + const downloadPath = await tc.downloadTool(downloadUrl); + core.info(`Downloaded to ${downloadPath}`); + + // Extract the zip archive (contains covdbg.exe and libcovdbg.dll) + const extractPath = await tc.extractZip(downloadPath); + core.info(`Extracted to ${extractPath}`); + + // Cache the tool for future runs + const cachedPath = await tc.cacheDir(extractPath, 'covdbg', version); + core.info(`Cached at ${cachedPath}`); + + // Add the tool to the PATH (both covdbg.exe and libcovdbg.dll are in this directory) + core.addPath(cachedPath); + core.info(`Added ${cachedPath} to PATH`); + + // Set the output + core.setOutput('covdbg-path', cachedPath); + + core.info('Successfully set up covdbg'); + } catch (error) { + if (error instanceof Error) { + core.setFailed(error.message); + } else { + core.setFailed('An unknown error occurred'); + } + } +} + +run(); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d25dc03 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["ES2020"], + "outDir": "./lib", + "rootDir": "./src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "lib"] +}