Skip to content

Fix Azure Devops pipeline and Github actions example to use latest grate in the pipelines #1400

Fix Azure Devops pipeline and Github actions example to use latest grate in the pipelines

Fix Azure Devops pipeline and Github actions example to use latest grate in the pipelines #1400

Workflow file for this run

# This is alight weight build and test, suitable for rapid checks of commits on feature branches etc.
name: CI
on:
push: # Trigger on pushes to feature branches for safety before a PR
branches-ignore:
- main # don't run on main (build.yml handles that)
paths-ignore:
- docs/
pull_request:
branches:
- main
paths-ignore:
- docs/
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-code:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: |
dotnet restore -r linux-x64 grate.sln
- name: Build
run: dotnet build -f net8.0 --no-restore --no-self-contained -r linux-x64 src/grate/grate.csproj -c release
analyze:
name: Analyze Code Security
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
test:
name: Run tests
runs-on: ubuntu-latest
#needs: build-code
strategy:
fail-fast: false
matrix:
category: [ "Basic_tests", "SqlServer", "PostgreSQL", "MariaDB", "Sqlite", "Oracle" ]
#category: [ "Basic_tests", "Sqlite" ]
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Test
run: |
dotnet test \
unittests/${{ matrix.category }} \
--logger:"xunit;LogFilePath=/tmp/test-results/${{ matrix.category }}.xml" -- \
-MaxCpuCount 2
env:
LogLevel: Warning
TZ: UTC
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.category }} XML test results"
path: |
/tmp/test-results/${{ matrix.category }}.xml
retention-days: 1
report:
runs-on: ubuntu-latest
name: Create test report
needs: test
steps:
- name: Download XML test reports
uses: actions/download-artifact@v4
with:
path: test-results
- name: Install smink
run: |
BASEURL="https://github.com/erikbra/smink/releases/download/"
VERSION="0.2.0"
INSTALL_DIR="/tmp/smink"
SMINK="${INSTALL_DIR}/smink"
FILENAME="smink-linux-x64-${VERSION}.zip"
FULL_URL="${BASEURL}${VERSION}/${FILENAME}"
DOWNLOAD_DIR="/tmp/smink-download"
DOWNLOAD_FILE="${DOWNLOAD_DIR}/${FILENAME}"
test -f "${SMINK}" && \
echo "smink already installed - not installing" || \
echo "Installing smink v ${VERSION}" && \
(test -d "${DOWNLOAD_DIR}" || mkdir -p "${DOWNLOAD_DIR}") && \
(test -d "${INSTALL_DIR}" || mkdir -p "${INSTALL_DIR}") && \
(test -f "${DOWNLOAD_FILE}" || curl -o "${DOWNLOAD_FILE}" -sL "${FULL_URL}") && \
unzip -o "${DOWNLOAD_FILE}" -d "${INSTALL_DIR}"
chmod u+x "${SMINK}"
- name: Create HTML test report
run: |
XML_DIR='/tmp/xml'
REPORT_DIR='/tmp/test-results'
test -d $XML_DIR || mkdir $XML_DIR
find "test-results" -name '*.xml' -exec cp "{}" $XML_DIR \;
echo "Found the following test results files:"
ls -1 $XML_DIR
test -d $REPORT_DIR || mkdir $REPORT_DIR
echo "Running smink"
/tmp/smink/smink "${XML_DIR}/*.xml" "${REPORT_DIR}/test-report.html" --title "grate unit tests"
- name: Upload HTML test report
uses: actions/upload-artifact@v4
with:
name: HTML test report
path: |
/tmp/test-results/test-report.html
retention-days: 1