Feature/implement tests #85
Workflow file for this run
This file contains 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: publish | |
on: | |
push: | |
branches: ["main"] | |
tags: ["v*.*.*"] # Publish semver tags as releases. | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build-and-test: | |
environment: 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 src/Hooki | |
- name: Build | |
run: dotnet build src/Hooki --configuration Release --no-restore | |
- name: Run Unit Tests | |
run: dotnet test src/Hooki.UnitTests/Hooki.UnitTests.csproj --no-restore | |
- name: Log Environment Variables | |
run: | | |
echo "Checking environment variables:" | |
[ -n "$DOTNET_ENVIRONMENT" ] && echo "DOTNET_ENVIRONMENT is set" || echo "DOTNET_ENVIRONMENT is not set" | |
[ -n "$TEST_DISCORD_WEBHOOK_URL" ] && echo "TEST_DISCORD_WEBHOOK_URL is set" || echo "TEST_DISCORD_WEBHOOK_URL is not set" | |
[ -n "$TEST_MICROSOFT_TEAMS_WEBHOOK_URL" ] && echo "TEST_MICROSOFT_TEAMS_WEBHOOK_URL is set" || echo "TEST_MICROSOFT_TEAMS_WEBHOOK_URL is not set" | |
[ -n "$TEST_SLACK_WEBHOOK_URL" ] && echo "TEST_SLACK_WEBHOOK_URL is set" || echo "TEST_SLACK_WEBHOOK_URL is not set" | |
[ -n "$TEST_PIPEDREAM_URL" ] && echo "TEST_PIPEDREAM_URL is set" || echo "TEST_PIPEDREAM_URL is not set" | |
[ -n "$TEST_IMAGE_FILE_NAME" ] && echo "TEST_IMAGE_FILE_NAME is set" || echo "TEST_IMAGE_FILE_NAME is not set" | |
[ -n "$TEST_IMAGE_CLOUD_URL" ] && echo "TEST_IMAGE_CLOUD_URL is set" || echo "TEST_IMAGE_CLOUD_URL is not set" | |
env: | |
DOTNET_ENVIRONMENT: ${{ vars.DOTNET_ENVIRONMENT }} | |
TEST_DISCORD_WEBHOOK_URL: ${{ secrets.TEST_DISCORD_WEBHOOK_URL }} | |
TEST_MICROSOFT_TEAMS_WEBHOOK_URL: ${{ secrets.TEST_MICROSOFT_TEAMS_WEBHOOK_URL }} | |
TEST_SLACK_WEBHOOK_URL: ${{ secrets.TEST_SLACK_WEBHOOK_URL }} | |
TEST_PIPEDREAM_URL: ${{ secrets.TEST_PIPEDREAM_URL }} | |
TEST_IMAGE_FILE_NAME: ${{ vars.TEST_IMAGE_FILE_NAME }} | |
TEST_IMAGE_CLOUD_URL: ${{ secrets.TEST_IMAGE_CLOUD_URL }} | |
- name: Run Integration Tests | |
env: | |
DOTNET_ENVIRONMENT: ${{ vars.DOTNET_ENVIRONMENT }} | |
TEST_DISCORD_WEBHOOK_URL: ${{ secrets.TEST_DISCORD_WEBHOOK_URL }} | |
TEST_MICROSOFT_TEAMS_WEBHOOK_URL: ${{ secrets.TEST_MICROSOFT_TEAMS_WEBHOOK_URL }} | |
TEST_SLACK_WEBHOOK_URL: ${{ secrets.TEST_SLACK_WEBHOOK_URL }} | |
TEST_PIPEDREAM_URL: ${{ secrets.TEST_PIPEDREAM_URL }} | |
TEST_IMAGE_FILE_NAME: ${{ vars.TEST_IMAGE_FILE_NAME }} | |
TEST_IMAGE_CLOUD_URL: ${{ secrets.TEST_IMAGE_CLOUD_URL }} | |
run: dotnet test src/Hooki.IntegrationTests/Hooki.IntegrationTests.csproj --no-restore | |
pack-and-publish: | |
needs: build-and-test | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
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 src/Hooki | |
- name: Build | |
run: dotnet build src/Hooki --configuration Release --no-restore | |
- name: Set version and trim leading 'v' | |
run: | | |
version=$(echo ${{ github.ref_name }} | sed 's/^v//') | |
echo "VERSION=$version" >> $GITHUB_ENV | |
echo "Set VERSION to $version" | |
- name: Pack | |
run: dotnet pack src/Hooki/Hooki.csproj --configuration Release --no-build -p:PackageVersion=${{env.VERSION}} --output ./nupkgs | |
- name: Publish to NuGet | |
run: dotnet nuget push "./nupkgs/Hooki.*" --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate |