Skip to content

WIP: proper handling of windows service lifecycle #970

WIP: proper handling of windows service lifecycle

WIP: proper handling of windows service lifecycle #970

name: Tests
on:
push:
branches: [ main, dev ]
paths-ignore:
- 'docs_src/**'
- 'README.md'
- 'CHANGELOG.md'
- 'CITATION'
- 'book.toml'
- 'CONTRIBUTING.md'
- '.github/workflows/exe-release-prometheuspush.yml'
pull_request:
branches: [ main, dev ]
paths-ignore:
- 'docs_src/**'
- 'README.md'
- 'CHANGELOG.md'
- 'CITATION'
- 'book.toml'
- '.github/workflows/exe-release-prometheuspush.yml'
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check_pr_is_on_the_right_branch:
name: Check PR is open on the right branch
runs-on: ubuntu-latest
steps:
- name: Display warning and kill pipeline if needed
run: |
if [ ${GITHUB_BASE_REF} == "main" && ${GITHUB_HEAD_REF} != "dev" ]; then
echo "PR has been opened on the main branch, from another branch than dev. Please consider opening it on the dev branch instead !"
exit 1
fi
fmt_and_clippy_linux:
name: Cargo Fmt and Clippy - Linux
runs-on: ubuntu-latest
needs: check_pr_is_on_the_right_branch
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: bpetit/[email protected]
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
- name: Check formatting
uses: bpetit/[email protected]
with:
command: fmt
args: --all -- --check
- name: Clippy Check
uses: bpetit/[email protected]
with:
command: clippy
args: -- -A clippy::upper_case_acronyms -D warnings
fmt_and_clippy_windows:
name: Cargo Fmt and Clippy - Windows
runs-on: windows-latest
needs: check_pr_is_on_the_right_branch
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rustup
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install rustup.install --ignore-checksums
- name: Install Rust toolchain
run: |
rustup toolchain install stable-x86_64-pc-windows-msvc
- name: Check formatting
uses: bpetit/[email protected]
with:
command: fmt
args: --all -- --check
- name: Clippy Check
uses: bpetit/[email protected]
with:
command : clippy
args: --no-default-features --features "prometheus json riemann warpten"
test_linux_x86_64:
name: Test on GNU/Linux x86_64 (Bare metal worker)
runs-on: ubuntu-latest
steps:
- name: Install dependencies (awxkit)
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install python requirements (awxkit)
run: |
python -m pip install --upgrade pip
pip install awxkit setuptools
- name: Log on AWX
id: login
run: |
export AWX_TOKEN=$(awx --conf.host "${{ secrets.AWX_HOST }}" --conf.username "${{ secrets.AWX_PUBLIC_USER }}" --conf.password "${{ secrets.AWX_PASSWORD }}" login | jq .token | tr -d '"')
echo "awx_token=${AWX_TOKEN}" >> $GITHUB_OUTPUT
- name: Prepare Rust environment on bare metal worker
id: rust
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"$GITHUB_REPOSITORY\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 12 --monitor
- name: Clone Scaphandre repository
id: clone
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 13 --monitor
- name: Run Unit Tests
id: unittests
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 14 --monitor
build_linux_x86_64:
name: Build on GNU/Linux x86_64 (Bare metal worker)
runs-on: ubuntu-latest
needs:
- fmt_and_clippy_linux
- test_linux_x86_64
steps:
- name: Install dependencies (awxkit)
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install python requirements (awxkit)
run: |
python -m pip install --upgrade pip
pip install awxkit
- name: Log on AWX
id: login
run: |
export AWX_TOKEN=$(awx --conf.host "${{ secrets.AWX_HOST }}" --conf.username "${{ secrets.AWX_PUBLIC_USER }}" --conf.password "${{ secrets.AWX_PASSWORD }}" login | jq .token | tr -d '"')
echo "awx_token=${AWX_TOKEN}" >> $GITHUB_OUTPUT
- name: Build debug version
id: builddebug
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 17 --monitor
- name: Test JSON exporter
id: jsonexporter
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 18 --monitor
- name: Build Docker image
id: dockerbuild
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 15 --monitor
- name: Test Scaphandre + Prometheus in docker-compose
id: promtest
run: |
awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ secrets.AWX_HOST }} job_templates launch --extra_vars="{\"github_repository\":\"${GITHUB_REPOSITORY}\",\"github_actor\":\"${GITHUB_ACTOR}\",\"github_workflow\":\"${GITHUB_WORKFLOW}\",\"github_workspace\":\"${GITHUB_WORKSPACE}\",\"github_event_name\":\"${GITHUB_EVENT_NAME}\",\"github_event_path\":\"${GITHUB_EVENT_PATH}\",\"github_sha\":\"${GITHUB_SHA}\",\"github_ref\":\"${GITHUB_REF}\",\"github_head_ref\":\"${GITHUB_HEAD_REF}\",\"github_base_ref\":\"${GITHUB_BASE_REF}\",\"github_server_url\":\"${GITHUB_SERVER_URL}\"}" 16 --monitor
test_windows_x86_64:
name: Test on Windows x86_64 (Virtual machine worker)
runs-on: "windows-latest"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install openssl for Windows with vcpkg
run: |
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
vcpkg install openssl:x64-windows-static-md
- name: Install Rustup
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install rustup.install --ignore-checksums
- name: Install Rust toolchain
run: |
rustup toolchain install stable-x86_64-pc-windows-msvc
- name: Tests
run: |
cargo test --no-default-features --features "prometheus prometheuspush json riemann" exporters
- name: Build (debug mode)
run: |
cargo build --no-default-features --features "prometheus prometheuspush json riemann"