Got it — you want to run a GitHub Actions pipeline locally to test performance for your .NET Core 8 microservice.
Running GitHub Actions locally is a common need during development, especially for fast iteration without pushing to GitHub every time.
Here’s a detailed guide:
1. Use act
act is the most popular tool to run GitHub Actions locally.
It interprets your .github/workflows/*.yml files and runs them inside Docker containers.
2. Install act
You can install act via:
3. Prepare your environment
- Make sure you have Docker installed and running.
- Make sure your
.github/workflows/your-pipeline.yml exists.
- If your workflow uses secrets, you can pass them via
--secret or a .secrets file.
Example .secrets file:
code
MY_SECRET=supersecretvalue
4. Run your GitHub Actions workflow locally
Basic usage:
This will run the default event (push) on the default workflow.
If you want to specify an event:
bash
act pull_request
If you want to run a specific job:
bash
act -j job_name
If you want to run a specific workflow file:
bash
act -W .github/workflows/your-workflow.yml
5. Customize the Docker image (for .NET 8)
By default, act uses a small image (node:16-buster-slim), but for .NET 8 you probably need a bigger image.
You can specify a larger image:
bash
act --container-architecture linux/amd64 --image ubuntu-latest
Or configure a custom image in .actrc:
code
-P ubuntu-latest=catthehacker/ubuntu:act-latest
The catthehacker/ubuntu:act-latest image is a popular choice because it mimics GitHub-hosted runners.
6. Example: Performance Testing Pipeline for .NET 8
Suppose you have a workflow like:
yaml
name: Performance Test
on:
push:
branches: [ main ]
pull_request:
jobs:
perf-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release
- name: Run performance tests
run: dotnet test --filter Category=Performance
You can run it locally with:
bash
act -j perf-test
7. Tips for Performance Testing
- Use BenchmarkDotNet for micro-benchmarking in .NET.
- Tag your tests with
[Category("Performance")] so you can filter them.
- Use
dotnet test --filter to only run performance tests.
- Profile resource usage (CPU, memory) if needed.
8. Limitations of act
- Some GitHub Actions features (like matrix builds, service containers) are partially supported.
- Some marketplace actions might not work exactly the same.
- Windows runners are not fully supported (Linux containers only).
If you need full fidelity, you might still need to push to GitHub occasionally.
9. Alternative: Self-hosted GitHub Runner
If you want full GitHub Actions behavior locally, you can set up a self-hosted runner on your machine.
- Install a GitHub runner agent.
- Register it to your repo.
- Run workflows targeting your local machine.
This is heavier but gives 100% compatibility.
Summary
| Option | Pros | Cons |
|---|
act | Fast, lightweight, easy | Some limitations |
| Self-hosted runner | Full GitHub Actions behavior | Heavier setup |
Quick Start Commands
bash
brew install act
act -j perf-test
Bonus: .actrc file
You can create a .actrc file in your repo root to configure defaults:
code
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-s MY_SECRET=supersecretvalue
Then just run:
and it will pick up the settings.
🚀 Final Note
For performance testing of a .NET 8 microservice, using act is a great way to iterate fast locally before pushing to GitHub.
If you want, I can also help you design a performance testing strategy (e.g., using BenchmarkDotNet, k6, or custom load tests) — just ask!
Would you like me to show you an example of a BenchmarkDotNet performance test project for your microservice too? 🚀