|
1 | | -name: build_and_test |
| 1 | +name: Tests |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ main, dev ] |
| 5 | + branches: [main, dev] |
6 | 6 | paths-ignore: |
7 | | - - 'docs_src/**' |
8 | | - - 'README.md' |
9 | | - - 'CHANGELOG.md' |
10 | | - - 'CITATION' |
11 | | - - 'book.toml' |
12 | | - - 'CONTRIBUTING.md' |
| 7 | + - "docs_src/**" |
| 8 | + - "README.md" |
| 9 | + - "CHANGELOG.md" |
| 10 | + - "CITATION" |
| 11 | + - "book.toml" |
| 12 | + - "CONTRIBUTING.md" |
| 13 | + - ".github/workflows/exe-release-prometheuspush.yml" |
| 14 | + - "*.md" |
| 15 | + - "oranda.json" |
13 | 16 | pull_request: |
14 | | - branches: [ main, dev ] |
| 17 | + branches: [main, dev] |
| 18 | + paths-ignore: |
| 19 | + - "docs_src/**" |
| 20 | + - "README.md" |
| 21 | + - "CHANGELOG.md" |
| 22 | + - "CITATION" |
| 23 | + - "book.toml" |
| 24 | + - ".github/workflows/exe-release-prometheuspush.yml" |
| 25 | + - "*.md" |
| 26 | + - "oranda.json" |
15 | 27 |
|
16 | 28 | env: |
17 | 29 | CARGO_TERM_COLOR: always |
18 | | - AWX_PUBLIC_ACCESS: "{Xs%g5/a/Si=;_[4LL" |
19 | | - AWX_PUBLIC_USER: "scaphandre-public" |
20 | | - AWX_HOST: "https://cd.hubblo.org" |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 33 | + cancel-in-progress: true |
21 | 34 |
|
22 | 35 | jobs: |
23 | | - build: |
24 | | - name: build_and_test_x86_64 |
| 36 | + check_pr_is_on_the_right_branch: |
| 37 | + name: Check PR is open on the right branch |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Display warning and kill pipeline if needed |
| 41 | + run: | |
| 42 | + if [ ${GITHUB_BASE_REF} == "main" && ${GITHUB_HEAD_REF} != "dev" ]; then |
| 43 | + echo "PR has been opened on the main branch, from another branch than dev. Please consider opening it on the dev branch instead !" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + fmt_and_clippy_linux: |
| 47 | + name: Cargo Fmt and Clippy - Linux |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: check_pr_is_on_the_right_branch |
| 50 | + steps: |
| 51 | + - name: Checkout repository |
| 52 | + uses: actions/checkout@v3 |
| 53 | + - name: Install Rust |
| 54 | + uses: bpetit/action-toolchain@v2.0.0 |
| 55 | + with: |
| 56 | + toolchain: stable |
| 57 | + profile: minimal |
| 58 | + override: true |
| 59 | + components: rustfmt |
| 60 | + - name: Check formatting |
| 61 | + uses: bpetit/action-cargo@v2.0.1 |
| 62 | + with: |
| 63 | + command: fmt |
| 64 | + args: --all -- --check |
| 65 | + - name: Clippy Check |
| 66 | + uses: bpetit/action-cargo@v2.0.1 |
| 67 | + with: |
| 68 | + command: clippy |
| 69 | + args: -- -A clippy::upper_case_acronyms -D warnings |
| 70 | + |
| 71 | + #fmt_and_clippy_windows: |
| 72 | + # name: Cargo Fmt and Clippy - Windows |
| 73 | + # runs-on: windows-latest |
| 74 | + # needs: check_pr_is_on_the_right_branch |
| 75 | + # steps: |
| 76 | + # - name: Checkout |
| 77 | + # uses: actions/checkout@v3 |
| 78 | + # - name: Install Rustup |
| 79 | + # uses: crazy-max/ghaction-chocolatey@v2 |
| 80 | + # with: |
| 81 | + # args: install rustup.install --ignore-checksums |
| 82 | + # - name: Install Rust toolchain |
| 83 | + # run: | |
| 84 | + # rustup toolchain install stable-x86_64-pc-windows-msvc |
| 85 | + # - name: Check formatting |
| 86 | + # uses: bpetit/action-cargo@v2.0.1 |
| 87 | + # with: |
| 88 | + # command: fmt |
| 89 | + # args: --all -- --check |
| 90 | + # - name: Clippy Check |
| 91 | + # uses: bpetit/action-cargo@v2.0.1 |
| 92 | + # with: |
| 93 | + # command : clippy |
| 94 | + # args: --no-default-features --features "prometheus json riemann warpten" |
| 95 | + |
| 96 | + test_linux_x86_64: |
| 97 | + name: Test on GNU/Linux x86_64 (Bare metal worker) |
25 | 98 | runs-on: ubuntu-latest |
26 | 99 | steps: |
27 | 100 | - name: Install dependencies (awxkit) |
28 | | - uses: actions/setup-python@v2 |
| 101 | + uses: actions/setup-python@v3 |
29 | 102 | with: |
30 | | - python-version: '3.x' |
| 103 | + python-version: "3.11" |
| 104 | + - name: Install python requirements (awxkit) |
| 105 | + run: | |
| 106 | + python -m pip install --upgrade pip |
| 107 | + pip install awxkit setuptools |
| 108 | + - name: Log on AWX |
| 109 | + id: login |
| 110 | + run: | |
| 111 | + 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 '"') |
| 112 | + echo "awx_token=${AWX_TOKEN}" >> $GITHUB_OUTPUT |
| 113 | + - name: Prepare Rust environment on bare metal worker |
| 114 | + id: rust |
| 115 | + run: | |
| 116 | + 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 |
| 117 | + - name: Clone Scaphandre repository |
| 118 | + id: clone |
| 119 | + run: | |
| 120 | + 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 |
| 121 | + - name: Run Unit Tests |
| 122 | + id: unittests |
| 123 | + run: | |
| 124 | + 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 |
| 125 | + build_linux_x86_64: |
| 126 | + name: Build on GNU/Linux x86_64 (Bare metal worker) |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: |
| 129 | + - fmt_and_clippy_linux |
| 130 | + - test_linux_x86_64 |
| 131 | + steps: |
| 132 | + - name: Install dependencies (awxkit) |
| 133 | + uses: actions/setup-python@v3 |
| 134 | + with: |
| 135 | + python-version: "3.11" |
31 | 136 | - name: Install python requirements (awxkit) |
32 | 137 | run: | |
33 | 138 | python -m pip install --upgrade pip |
34 | 139 | pip install awxkit |
35 | | - - name: Log on AWX |
| 140 | + - name: Log on AWX |
36 | 141 | id: login |
37 | 142 | run: | |
38 | | - export AWX_TOKEN=$(awx --conf.host "${{env.AWX_HOST}}" --conf.username "${{env.AWX_PUBLIC_USER}}" --conf.password "${{env.AWX_PUBLIC_ACCESS}}" login | jq .token | tr -d '"') |
39 | | - echo "::set-output name=awx_token::${AWX_TOKEN}" |
40 | | - - name: Launch job |
41 | | - id: launch |
| 143 | + 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 '"') |
| 144 | + echo "awx_token=${AWX_TOKEN}" >> $GITHUB_OUTPUT |
| 145 | + - name: Build debug version |
| 146 | + id: builddebug |
| 147 | + run: | |
| 148 | + 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 |
| 149 | + - name: Test JSON exporter |
| 150 | + id: jsonexporter |
| 151 | + run: | |
| 152 | + 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 |
| 153 | + - name: Build Docker image |
| 154 | + id: dockerbuild |
| 155 | + run: | |
| 156 | + 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 |
| 157 | + - name: Test Scaphandre + Prometheus in docker-compose |
| 158 | + id: promtest |
42 | 159 | run: | |
43 | | - awx --conf.token ${{ steps.login.outputs.awx_token }} --conf.host ${{ env.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}\"}" 9 --monitor |
| 160 | + 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 |
| 161 | + #test_windows_x86_64: |
| 162 | + # name: Test on Windows x86_64 (Virtual machine worker) |
| 163 | + # runs-on: "windows-latest" |
| 164 | + # steps: |
| 165 | + # - name: Checkout |
| 166 | + # uses: actions/checkout@v3 |
| 167 | + # - name: Install openssl for Windows with vcpkg |
| 168 | + # run: | |
| 169 | + # echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 170 | + # vcpkg install openssl:x64-windows-static-md |
| 171 | + # - name: Install Rustup |
| 172 | + # uses: crazy-max/ghaction-chocolatey@v2 |
| 173 | + # with: |
| 174 | + # args: install rustup.install --ignore-checksums |
| 175 | + # - name: Install Rust toolchain |
| 176 | + # run: | |
| 177 | + # rustup toolchain install stable-x86_64-pc-windows-msvc |
| 178 | + # - name: Tests |
| 179 | + # run: | |
| 180 | + # cargo test --no-default-features --features "prometheus prometheuspush json riemann" exporters |
| 181 | + # - name: Build (debug mode) |
| 182 | + # run: | |
| 183 | + # cargo build --no-default-features --features "prometheus prometheuspush json riemann" |
0 commit comments