Skip to content

add delete network area and test (#381) #1711

add delete network area and test (#381)

add delete network area and test (#381) #1711

Workflow file for this run

name: CI
on:
push:
pull_request:
# Allow manual runs. It is necessary to run the workflow manually, when the "formatter" workflow applies any changes.
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
# Enforces the consistency of code formatting using `.editorconfig` and the `dotnet format`.
check-format:
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
# For the time being (https://github.com/dotnet/format/issues/1500, https://github.com/dotnet/format/issues/1560) we need to use `dotnet-format` instead of `dotnet format`
- name: Restore tool
run: dotnet tool restore
- name: Check format
run: dotnet tool run dotnet-format -- --check
Consul_AspNetCore:
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-13] # macos-13 for x86_x64 arch
framework: [net6.0, net7.0, net8.0]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK v6.0.x
if: matrix.framework == 'net6.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup .NET SDK v7.0.x
if: matrix.framework == 'net7.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
- name: Build
run: dotnet build Consul.AspNetCore.Test --configuration=Release --framework=${{ matrix.framework }}
- name: Run tests
shell: bash
run: dotnet test Consul.AspNetCore.Test --configuration=Release --logger "GitHubActions;report-warnings=false" --no-build -v=Normal --framework=${{ matrix.framework }}
Consul:
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
strategy:
matrix:
consul: [1.7.14, 1.8.19, 1.9.17, 1.10.12, 1.11.11, 1.12.9, 1.13.9, 1.14.11, 1.15.10, 1.16.6, 1.17.3, 1.18.2, 1.19.2, 1.20.0]
framework: [net461, net6.0, net7.0, net8.0]
os: [ubuntu-latest, windows-latest, macos-latest, macos-13] # macos-13 for x86_x64 arch
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK v6.0.x
if: matrix.framework == 'net6.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup .NET SDK v7.0.x
if: matrix.framework == 'net7.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
- name: Setup Consul Enterprise URL
# Consul enterprise until version 1.10.0 can be run even without a valid license,
# so we take advantage of that and run enterprise tests for versions lower than 1.10.0.
# This is still necessary although a valid license has been configured in the repository settings
# because the license secret is unavailable when the pull request is created from a fork.
if: ${{ env.CONSUL_LICENSE != '' || startsWith(matrix.consul, '1.7.') || startsWith(matrix.consul, '1.8.') || startsWith(matrix.consul, '1.9.') }}
run: |
echo "RUN_CONSUL_ENTERPRISE_TESTS=1" >> $GITHUB_ENV
- name: Set up mono
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt install mono-complete
# We've decided to pause using the CONSUL_LICENSE for tests because the license would need to be renewed periodically.
# Otherwise, new builds of consul are going to fail with "license expiration date is before version build date" errors.
# Mind that, we are still running enterprise 1.10.0.
# env:
# CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }}
- name: Download Consul
shell: bash
run: |
cd Consul.Test
SYSTEM=$(uname | sed 's/MINGW.*/windows/' | tr A-Z a-z)
if [[ $RUN_CONSUL_ENTERPRISE_TESTS == 1 ]]
then
curl -sSL https://releases.hashicorp.com/consul/${{ matrix.consul }}+ent/consul_${{ matrix.consul }}+ent_${SYSTEM}_amd64.zip -o consul.zip
else
curl -sSL https://releases.hashicorp.com/consul/${{ matrix.consul }}/consul_${{ matrix.consul }}_${SYSTEM}_amd64.zip -o consul.zip
fi
unzip consul.zip
rm consul.zip
- name: Build
run: dotnet build Consul.Test --configuration=Release --framework=${{ matrix.framework }}
- name: Run tests
shell: bash
run: |
./Consul.Test/consul agent -dev -config-file Consul.Test/test_config.json -log-file consul.log >consul-stdout.log 2>consul-stderr.log &
dotnet test Consul.Test --configuration=Release --logger "GitHubActions;report-warnings=false" --no-build -v=Normal --framework=${{ matrix.framework }}
env:
RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }}
CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }}
CONSUL_AGENT_CONFIG_PATH: ${{ github.workspace }}/Consul.Test/test_config.json
- name: Upload Consul logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: consul-logs-${{ matrix.consul }}-${{ matrix.framework }}-${{ matrix.os }}
path: consul*.log
package:
runs-on: windows-latest
needs: [Consul_AspNetCore, Consul]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
- name: Create NuGet packages
run: |
if (-not ("${{ github.ref }}" -like "refs/tags/v*")) {
$suffix = "preview-$(Get-Date -Format yyyyMMddHHmmss -AsUTC)-$(git rev-parse --short HEAD)"
$params = "--version-suffix", $suffix
}
dotnet pack --configuration=Release --output dist @params
if ("${{ github.ref }}" -like "refs/tags/v*") {
$tag = "${{ github.ref }}".SubString(11)
$expectedConsulFile = "dist/Consul.$tag.nupkg"
$expectedConsulAspNetCoreFile = "dist/Consul.AspNetCore.$tag.nupkg"
# Check whether the tag and the package version match together
if (-not (Test-Path -Path $expectedConsulFile)) {
echo "::error ::Expected file $expectedConsulFile doesn't exist"
exit 1
}
if (-not (Test-Path -Path $expectedConsulAspNetCoreFile)) {
echo "::error ::Expected file $expectedConsulAspNetCoreFile doesn't exist"
exit 1
}
}
- name: Upload NuGet package artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: dist/*.nupkg
# Publish NuGet packages to the preview feed when there is a push to master.
# Tests need to succeed for all components and on all platforms first.
publish-preview:
if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/master' }}
needs: package
runs-on: ubuntu-latest
steps:
- name: Download NuGet package artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: dist
- name: Publish to NuGet
run: dotnet nuget push "dist/Consul.*.nupkg" --api-key ${{ secrets.FEEDZIO_API_KEY }} --source https://f.feedz.io/consuldotnet/preview/nuget/index.json
# Publish NuGet packages when a tag is pushed.
# Tests need to succeed for all components and on all platforms first,
# including having a tag name that matches the version number.
publish-release:
if: ${{ !github.event.repository.fork && startsWith(github.ref, 'refs/tags/v') }}
needs: package
runs-on: ubuntu-latest
steps:
- name: Download NuGet package artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: dist
- name: Publish to NuGet
run: dotnet nuget push "dist/Consul.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json