Skip to content

Commit 6f290ce

Browse files
committed
feat: implement setup-probitas GitHub Action
Add composite action for setting up Probitas testing framework in GitHub Actions workflows. Features: - Automatic Deno and Probitas CLI installation - Version selection for both Deno and Probitas - Built-in caching support via setup-deno - Multi-OS support (Ubuntu, macOS, Windows) - Comprehensive test workflow - Basic usage example with sample scenario The action leverages denoland/setup-deno internally and installs Probitas CLI from JSR.
1 parent 820b1d7 commit 6f290ce

File tree

7 files changed

+423
-0
lines changed

7 files changed

+423
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto eol=lf
2+
*.yml text eol=lf
3+
*.yaml text eol=lf
4+
*.sh text eol=lf

.github/workflows/test.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-basic:
12+
name: Test Basic Setup
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Probitas
21+
uses: ./
22+
id: setup
23+
24+
- name: Verify Outputs
25+
shell: bash
26+
run: |
27+
echo "Cache Hit: ${{ steps.setup.outputs.cache-hit }}"
28+
echo "Deno Version: ${{ steps.setup.outputs.deno-version }}"
29+
echo "Probitas Version: ${{ steps.setup.outputs.probitas-version }}"
30+
31+
- name: Test Probitas CLI
32+
run: |
33+
probitas --version
34+
probitas --help
35+
36+
- name: Initialize Probitas Project
37+
run: probitas init
38+
39+
- name: Run Example Scenarios
40+
run: probitas run
41+
42+
test-versions:
43+
name: Test Version Selection
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
deno-version: [stable, lts]
48+
probitas-version: [latest]
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Setup Probitas with ${{ matrix.deno-version }}
53+
uses: ./
54+
with:
55+
deno-version: ${{ matrix.deno-version }}
56+
probitas-version: ${{ matrix.probitas-version }}
57+
58+
- name: Verify Installation
59+
run: |
60+
deno --version
61+
probitas --version
62+
63+
test-caching:
64+
name: Test Caching
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Setup Probitas with Cache
70+
uses: ./
71+
id: setup-with-cache
72+
with:
73+
cache: true
74+
75+
- name: Create Test Scenario
76+
run: |
77+
mkdir -p probitas
78+
cat > probitas/test.probitas.ts << 'EOF'
79+
import { scenario } from "probitas";
80+
81+
export default scenario("Test Scenario")
82+
.step("Hello", () => {
83+
console.log("Hello from Probitas!");
84+
return { success: true };
85+
})
86+
.build();
87+
EOF
88+
89+
- name: Run Test
90+
run: probitas run
91+
92+
- name: Check Cache Hit
93+
run: echo "Cache was ${{ steps.setup-with-cache.outputs.cache-hit && 'hit' || 'missed' }}"
94+
95+
test-no-cache:
96+
name: Test Without Cache
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v4
100+
101+
- name: Setup Probitas without Cache
102+
uses: ./
103+
with:
104+
cache: false
105+
106+
- name: Verify Installation
107+
run: probitas --version

README.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# setup-probitas
2+
3+
Set up your GitHub Actions workflow with [Probitas](https://github.com/jsr-probitas/probitas), a scenario-based testing framework for Deno.
4+
5+
## Usage
6+
7+
### Basic Setup
8+
9+
The simplest setup installs the latest stable Deno and Probitas versions:
10+
11+
```yaml
12+
- uses: jsr-probitas/setup-probitas@v1
13+
```
14+
15+
### Full Example Workflow
16+
17+
```yaml
18+
name: Test
19+
20+
on:
21+
push:
22+
branches: [main]
23+
pull_request:
24+
branches: [main]
25+
26+
jobs:
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: jsr-probitas/setup-probitas@v1
33+
with:
34+
deno-version: stable
35+
probitas-version: latest
36+
cache: true
37+
38+
- name: Run Probitas tests
39+
run: probitas run
40+
```
41+
42+
## Inputs
43+
44+
| Input | Description | Default |
45+
|-------|-------------|---------|
46+
| `deno-version` | The Deno version to install. Can be a semver version, `stable`, `lts`, `rc`, or `canary`. | `stable` |
47+
| `probitas-version` | The Probitas version to install from JSR. Can be a semver version or `latest`. | `latest` |
48+
| `cache` | Cache downloaded modules & packages automatically in GitHub Actions cache. | `true` |
49+
| `cache-hash` | A hash used as part of the cache key, which defaults to a hash of the deno.lock files. | - |
50+
51+
## Outputs
52+
53+
| Output | Description |
54+
|--------|-------------|
55+
| `cache-hit` | A boolean indicating whether the cache was hit. |
56+
| `deno-version` | The Deno version that was installed. |
57+
| `probitas-version` | The Probitas version that was installed. |
58+
59+
## Examples
60+
61+
### Specify Versions
62+
63+
```yaml
64+
- uses: jsr-probitas/setup-probitas@v1
65+
with:
66+
deno-version: "2.1.0"
67+
probitas-version: "0.1.0"
68+
```
69+
70+
### Use LTS Deno
71+
72+
```yaml
73+
- uses: jsr-probitas/setup-probitas@v1
74+
with:
75+
deno-version: lts
76+
```
77+
78+
### Disable Cache
79+
80+
```yaml
81+
- uses: jsr-probitas/setup-probitas@v1
82+
with:
83+
cache: false
84+
```
85+
86+
### Custom Cache Key
87+
88+
```yaml
89+
- uses: jsr-probitas/setup-probitas@v1
90+
with:
91+
cache-hash: ${{ hashFiles('**/deno.json', '**/deno.lock') }}
92+
```
93+
94+
### Matrix Testing
95+
96+
Test across multiple Deno versions:
97+
98+
```yaml
99+
jobs:
100+
test:
101+
runs-on: ubuntu-latest
102+
strategy:
103+
matrix:
104+
deno-version: [stable, lts, "2.0.0"]
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- uses: jsr-probitas/setup-probitas@v1
109+
with:
110+
deno-version: ${{ matrix.deno-version }}
111+
112+
- run: probitas run
113+
```
114+
115+
### Run with Selectors and Tags
116+
117+
```yaml
118+
- uses: jsr-probitas/setup-probitas@v1
119+
120+
- name: Run integration tests
121+
run: probitas run -s tag:integration
122+
123+
- name: Run with custom reporter
124+
run: probitas run --reporter json > results.json
125+
```
126+
127+
### Multiple Operating Systems
128+
129+
```yaml
130+
jobs:
131+
test:
132+
strategy:
133+
matrix:
134+
os: [ubuntu-latest, macos-latest, windows-latest]
135+
runs-on: ${{ matrix.os }}
136+
steps:
137+
- uses: actions/checkout@v4
138+
- uses: jsr-probitas/setup-probitas@v1
139+
- run: probitas run
140+
```
141+
142+
## How It Works
143+
144+
This action performs the following steps:
145+
146+
1. **Setup Deno**: Uses [denoland/setup-deno](https://github.com/denoland/setup-deno) to install Deno with the specified version and cache configuration
147+
2. **Install Probitas CLI**: Installs the Probitas CLI from JSR using `deno install`
148+
3. **Verify Installation**: Confirms both Deno and Probitas are correctly installed and available in the PATH
149+
150+
## Caching
151+
152+
Caching is enabled by default and helps speed up your workflows by:
153+
154+
- Caching Deno's compiled module cache
155+
- Caching downloaded dependencies based on your `deno.lock` file
156+
- Reducing network requests and installation time
157+
158+
The cache key is automatically generated based on:
159+
- The GitHub job ID
160+
- The runner OS and architecture
161+
- A hash of `deno.lock` files in your project (customizable via `cache-hash`)
162+
163+
## Related Projects
164+
165+
- [Probitas](https://github.com/jsr-probitas/probitas) - The main Probitas framework
166+
- [setup-deno](https://github.com/denoland/setup-deno) - Deno setup action (used internally)
167+
168+
## License
169+
170+
See [LICENSE](LICENSE) file for details.

action.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "Setup Probitas"
2+
description: "Setup Probitas by installing Deno and Probitas CLI, and adding them to the path."
3+
author: "JSR Probitas"
4+
branding:
5+
icon: "check-circle"
6+
color: "green"
7+
8+
inputs:
9+
deno-version:
10+
description: "The Deno version to install. Can be a semver version, 'canary', 'lts', 'rc', or 'stable'."
11+
default: "stable"
12+
probitas-version:
13+
description: "The Probitas version to install. Can be a semver version or 'latest'."
14+
default: "latest"
15+
cache:
16+
description: "Cache downloaded modules & packages automatically in GitHub Actions cache."
17+
default: "true"
18+
cache-hash:
19+
description: "A hash used as part of the cache key, which defaults to a hash of the deno.lock files."
20+
21+
outputs:
22+
cache-hit:
23+
description: "A boolean indicating whether the cache was hit."
24+
value: ${{ steps.setup-deno.outputs.cache-hit }}
25+
deno-version:
26+
description: "The Deno version that was installed."
27+
value: ${{ steps.setup-deno.outputs.deno-version }}
28+
probitas-version:
29+
description: "The Probitas version that was installed."
30+
value: ${{ steps.install-probitas.outputs.probitas-version }}
31+
32+
runs:
33+
using: "composite"
34+
steps:
35+
- name: Setup Deno
36+
id: setup-deno
37+
uses: denoland/setup-deno@v2
38+
with:
39+
deno-version: ${{ inputs.deno-version }}
40+
cache: ${{ inputs.cache }}
41+
cache-hash: ${{ inputs.cache-hash }}
42+
43+
- name: Install Probitas CLI
44+
id: install-probitas
45+
shell: bash
46+
run: |
47+
if [ "${{ inputs.probitas-version }}" = "latest" ]; then
48+
VERSION_FLAG=""
49+
else
50+
VERSION_FLAG="@${{ inputs.probitas-version }}"
51+
fi
52+
53+
echo "Installing Probitas CLI${VERSION_FLAG:+ version ${{ inputs.probitas-version }}}..."
54+
deno install -grAf -n probitas "jsr:@probitas/cli${VERSION_FLAG}"
55+
56+
# Verify installation
57+
if ! command -v probitas &> /dev/null; then
58+
echo "Error: Probitas CLI installation failed"
59+
exit 1
60+
fi
61+
62+
# Get installed version
63+
INSTALLED_VERSION=$(probitas --version 2>&1 | head -n 1)
64+
echo "Installed: $INSTALLED_VERSION"
65+
echo "probitas-version=$INSTALLED_VERSION" >> $GITHUB_OUTPUT
66+
67+
- name: Verify Probitas
68+
shell: bash
69+
run: |
70+
echo "Probitas CLI is ready:"
71+
probitas --version

examples/basic/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Basic Probitas Example
2+
3+
This is a minimal example project demonstrating Probitas usage with setup-probitas GitHub Action.
4+
5+
## Local Usage
6+
7+
```bash
8+
# Install Probitas CLI
9+
deno install -grAf -n probitas jsr:@probitas/cli
10+
11+
# Run scenarios
12+
probitas run
13+
14+
# Run with specific tags
15+
probitas run -s tag:example
16+
```
17+
18+
## GitHub Actions Usage
19+
20+
```yaml
21+
- uses: jsr-probitas/setup-probitas@v1
22+
23+
- name: Run tests
24+
run: probitas run
25+
```
26+
27+
## Project Structure
28+
29+
```
30+
.
31+
├── deno.json # Deno configuration with Probitas settings
32+
└── probitas/
33+
└── example.probitas.ts # Example test scenario
34+
```
35+
36+
## Learn More
37+
38+
- [Probitas Documentation](https://github.com/jsr-probitas/probitas)
39+
- [setup-probitas README](../../README.md)

0 commit comments

Comments
 (0)