Skip to content

test: e2e test

test: e2e test #265

Workflow file for this run

---
# Github workflow for Notation Azure Key Vault plugin
name: test
on:
push:
branches:
- main
- release-*
pull_request:
jobs:
lint:
name: Lint Code Base
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
statuses: write
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint Code Base
uses: super-linter/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
DEFAULT_WORKSPACE: ./Notation.Plugin.AzureKeyVault
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: .*Tests/.*
VALIDATE_MARKDOWN: false
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: "Build"
runs-on: ${{ matrix.os }}
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Check out code into the project directory
uses: actions/checkout@v3
- name: Run unit tests
run: make test
- name: Build testing
run: make build
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
# write an e2e-build job to build with ./scrpits/build.sh for linux, windows and macos,
# upload the artifacts
e2e-build:
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Check out code into the project directory
uses: actions/checkout@v3
- name: Build bianry
run: |
./scripts/build.sh v0.0.1 linux-x64
./scripts/build.sh v0.0.1 win-x64
./scripts/build.sh v0.0.1 osx-x64
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: linux-amd64-binary
path: ./bin/artifacts/notation-azure-kv_0.0.1_linux_amd64.tar.gz
retention-days: 1
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: darwin-amd64-binary
path: ./bin/artifacts/notation-azure-kv_0.0.1_darwin_amd64.tar.gz
retention-days: 1
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: win-amd64-binary
path: ./bin/artifacts/notation-azure-kv_0.0.1_windows_amd64.zip
retention-days: 1
e2e-linux:
runs-on: ubuntu-latest
needs: e2e-build
steps:
- name: Check out code into the project directory
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: linux-amd64-binary
path: ./bin/artifacts
- name: Run download server locally
run: |
nohup python3 ./.github/e2e/download-server/download-server.py &
# prepare the environment variables for E2E
artifactName=notation-azure-kv_0.0.1_linux_amd64.tar.gz
checksum=$(shasum -a 256 "./bin/artifacts/$artifactName" | awk '{print $1}')
echo "pluginChecksum=$checksum" >> $GITHUB_ENV
echo "pluginDownloadURL=http://localhost:8000/$artifactName" >> $GITHUB_ENV
- name: Prepare container registry
run: |
docker run --name registry --rm -d -p 5000:5000 registry:2
docker pull hello-world:latest
docker tag hello-world:latest localhost:5000/hello-world:v1
docker push localhost:5000/hello-world:v1
- name: Azure login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: E2E testing
uses: ./.github/e2e
with:
pluginDownloadURL: ${{ env.pluginDownloadURL }}
pluginChecksum: ${{ env.pluginChecksum }}
e2e-windows:
runs-on: windows-2022
needs: e2e-build
steps:
- name: Check out code into the project directory
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: win-amd64-binary
path: ./bin/artifacts
- name: Run download server locally
run: |
schtasks /create /tn "downloadServer" /tr "python .\.github\e2e\download-server\download-server.py" /sc once /st 00:00 /du 23:59 /f
schtasks /run /tn "downloadServer"
$Url = "http://localhost:8000/notation-azure-kv_0.0.1_windows_amd64.zip"
$Output = "C:\Downloads\sample.zip"
Invoke-WebRequest -Uri $Url -OutFile $Output
ls $Output
# Prepare the environment variables for E2E
$artifactName = "notation-azure-kv_0.0.1_windows_amd64.zip"
$checksum = (Get-FileHash ".\bin\artifacts\$artifactName" -Algorithm SHA256).Hash
"pluginChecksum=$checksum" | Out-File -Append -FilePath $Env:GITHUB_ENV
"pluginDownloadURL=http://localhost:8000/$artifactName" | Out-File -Append -FilePath $Env:GITHUB_ENV
shell: pwsh
- name: Prepare container registry
run: |
docker build --build-arg IMAGE_VERSION=ltsc2022 -t registry:2 -f .\.github\e2e\registry\Dockerfile.windows .\.github\e2e\registry\
docker run --name registry --rm -d -p 5000:5000 registry:2
docker pull hello-world:latest
docker tag hello-world:latest localhost:5000/hello-world:v1
docker push localhost:5000/hello-world:v1
shell: pwsh
- name: Azure login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: E2E testing
uses: ./.github/e2e
with:
pluginDownloadURL: ${{ env.pluginDownloadURL }}
pluginChecksum: ${{ env.pluginChecksum }}