Skip to content

Commit

Permalink
Update common unit-test workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Sep 13, 2024
1 parent c5be9b3 commit 9017e20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 121 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/unit-test-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ permissions:
checks: write
pull-requests: write

env:
CONAN_LOGIN_USERNAME: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD: ${{ secrets.CONAN_PASS }}

jobs:
publish-test-results:
if: ${{ inputs.event == 'pull_request' }}
Expand Down Expand Up @@ -57,7 +53,7 @@ jobs:
echo "pr_head_repo=$(cat pr_env/pr-head-repo.txt)" >> $GITHUB_ENV
echo "pr_head_ref=$(cat pr_env/pr-head-ref.txt)" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: ${{ env.pr_head_repo }}
ref: ${{ env.pr_head_ref }}
Expand Down Expand Up @@ -95,7 +91,7 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action@v2
with:
github-token: ${{ secrets.CURA_UNIT_TESTS_POST_PAT }}
files: "tests/**/*.xml"
files: "tests/**/unit_tests_results.xml"

- name: Conclusion
run: echo "Conclusion is ${{ steps.test-results.outputs.json && fromJSON( steps.test-results.outputs.json ).conclusion }}"
131 changes: 16 additions & 115 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,136 +1,37 @@
---
name: unit-test

on:
workflow_call:
inputs:
recipe_id_full:
required: true
type: string

conan_extra_args:
required: false
default: ''
type: string

unit_test_cmd:
required: true
type: string

conan_generator_dir:
required: false
default: './build/Release/generators'
type: string

unit_test_dir:
required: true
type: string

build:
required: false
default: false
type: boolean

conan_internal:
test_use_ctest:
required: false
default: false
type: boolean

permissions:
contents: read

env:
CONAN_LOGIN_USERNAME: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD: ${{ secrets.CONAN_PASS }}

jobs:
testing:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
with:
fetch-depth: 1
ref: ${{ github.head_ref }}

- name: Checkout repo PR
uses: actions/checkout@v4
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
with:
fetch-depth: 1
ref: ${{ github.base_ref }}

- name: Sync pip requirements
run: wget https://raw.githubusercontent.com/Ultimaker/cura-workflows/main/.github/workflows/requirements-runner.txt -O .github/workflows/requirements-runner.txt

- name: Setup Python and pip
uses: actions/setup-python@v4
steps:
# FIXME: use main once merged
- name: Setup the build environment
uses: ultimaker/cura-workflows/.github/actions/setup-build-environment@CURA-11622_conan_v2
with:
python-version: 3.11.x
cache: pip
cache-dependency-path: .github/workflows/requirements-runner.txt
conan_user: ${{ secrets.CONAN_USER }}
conan_password: ${{ secrets.CONAN_PASS }}
install_system_dependencies: true

- name: Install Python requirements and Create default Conan profile
run: pip install -r .github/workflows/requirements-runner.txt
- name: Install dependencies and build unit test
run: conan build . -s build_type=Release --build=missing --update -g GitHubActionsRunEnv -g GitHubActionsBuildEnv -c tools.build:skip_test=False

- name: Install Linux system requirements for building
run: |
mkdir runner_scripts
wget https://raw.githubusercontent.com/Ultimaker/cura-workflows/main/runner_scripts/ubuntu_setup.sh -O runner_scripts/ubuntu_setup.sh
chmod +x runner_scripts/ubuntu_setup.sh
sudo ./runner_scripts/ubuntu_setup.sh
- name: Setup pipeline caches
run: |
mkdir -p /home/runner/.conan/downloads
- name: Create default Conan profile
run: conan profile new default --detect

- name: Get Conan configuration
run: |
conan config install https://github.com/Ultimaker/conan-config.git
conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
- name: Add Cura private Artifactory remote
if: ${{ inputs.conan_internal }}
run: |
conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/internal"
conan user -p ${{ secrets.CONAN_PASS }} -r cura-private ${{ secrets.CONAN_USER }}
- name: Cache Conan downloads
uses: actions/cache@v3
with:
path: /home/runner/.conan/downloads
key: ${{ runner.os }}-conan-downloads-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-conan-downloads-
- name: Install dependencies
run: conan install . ${{ inputs.recipe_id_full }} -s build_type=Release --build=missing --update -g GitHubActionsRunEnv -g GitHubActionsBuildEnv ${{ inputs.conan_extra_args }}

- name: Set Environment variables from Conan install (bash)
run: |
for file in activate_github_actions*.sh; do
if [ -f "$file" ]; then
. "./$file"
fi
done
echo "$PATH" >> $GITHUB_PATH
working-directory: ${{ inputs.conan_generator_dir }}

- name: Build
if: ${{ inputs.build == true }}
run: |
cmake --preset release
cmake --build --preset release
- name: Run Unit Test
- name: Run ctest-based unit test
if: ${{ inputs.test_use_ctest }}
id: run-test
run: ${{ inputs.unit_test_cmd }}
working-directory: ${{ inputs.unit_test_dir }}
run: ctest --output-junit unit_tests_results.xml
working-directory: build/Release/tests

- name: Save PR metadata
if: always()
Expand All @@ -142,11 +43,11 @@ jobs:

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-result
path: |
${{ inputs.unit_test_dir }}/**/*.xml
${{ inputs.unit_test_dir }}/**/unit_tests_results.xml
${{ inputs.unit_test_dir }}/pr-id.txt
${{ inputs.unit_test_dir }}/pr-head-repo.txt
${{ inputs.unit_test_dir }}/pr-head-ref.txt

0 comments on commit 9017e20

Please sign in to comment.