8000 Add Build Info demo and try to update art:build-info create-bundle to work with v2 bundles by czoido · Pull Request #179 · conan-io/conan-extensions · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Build Info demo and try to update art:build-info create-bundle to work with v2 bundles #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 74 additions & 22 deletions .github/workflows/test_conan_extensions.yml
8000
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,89 @@ on: [pull_request, workflow_dispatch]

jobs:
conan_linux:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
services:
artifactory:
image: releases-docker.jfrog.io/jfrog/artifactory-pro:latest
env:
JF_SHARED_DATABASE_TYPE: derby
JF_SHARED_DATABASE_ALLOWNONPOSTGRESQL: "true"
ports:
- 8081:8081
- 8082:8082
options: >-
--health-cmd "curl -f http://localhost:8081/artifactory/api/system/ping || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 10
--log-driver none
env:
CONAN_LOGIN_USERNAME_EXTENSIONS_PROD: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_EXTENSIONS_PROD: ${{ secrets.CONAN_PASSWORD }}
CONAN_LOGIN_USERNAME_EXTENSIONS_STG: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_EXTENSIONS_STG: ${{ secrets.CONAN_PASSWORD }}
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
ART_URL: ${{ secrets.ART_URL }}
CONAN_LOGIN_USERNAME_EXTENSIONS_PROD: ${{ secrets.ARTIFACTORY_USER }}
CONAN_PASSWORD_EXTENSIONS_PROD: ${{ secrets.ARTIFACTORY_USER_PASSWORD }}
CONAN_LOGIN_USERNAME_EXTENSIONS_STG: ${{ secrets.ARTIFACTORY_USER }}
CONAN_PASSWORD_EXTENSIONS_STG: ${{ secrets.ARTIFACTORY_USER_PASSWORD }}
ART_URL: http://localhost:8081/artifactory

steps:
- uses: actions/checkout@v3

- name: Check if Artifactory credentials are available
run: |
if [[ -n "${{ secrets.ARTIFACTORY_USER }}" && -n "${{ secrets.ARTIFACTORY_USER_PASSWORD }}" ]]; then
echo "HAS_ARTIFACTORY_CREDS=true" >> $GITHUB_ENV
else
echo "HAS_ARTIFACTORY_CREDS=false" >> $GITHUB_ENV
fi

- name: Wait for Artifactory to be ready
run: |
until curl -s http://localhost:8081/artifactory/api/system/ping; do
echo "Waiting for Artifactory to be ready..."
sleep 5
done

- name: Set Artifactory License
if: env.HAS_ARTIFACTORY_CREDS == 'true'
run: |
curl -u "${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_USER_PASSWORD }}" --output /dev/null \
-X POST "http://localhost:8081/artifactory/api/system/licenses" \
-H "Content-Type: application/json" \
-d "{ \"licenseKey\": \"${{ secrets.ARTIFACTORY_LICENSE }}\" }"

- name: Create Conan Local Repositories
if: env.HAS_ARTIFACTORY_CREDS == 'true'
run: |
curl -u "${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_USER_PASSWORD }}" --output /dev/null \
-X PUT "http://localhost:8081/artifactory/api/repositories/extensions-prod" \
-H "Content-Type: application/json" \
-d '{ "rclass": "local", "packageType": "conan", "repoLayoutRef": "conan-default", "description": "Local Conan repository for production" }'

curl -u "${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_USER_PASSWORD }}" --output /dev/null \
-X PUT "http://localhost:8081/artifactory/api/repositories/extensions-stg" \
-H "Content-Type: application/json" \
-d '{ "rclass": "local", "packageType": "conan", "repoLayoutRef": "conan-default", "description": "Local Conan repository for staging" }'

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: |
pip install -U pip
pip install pytest "cyclonedx-python-lib>=5.0.0,<6"

- name: Install Conan latest
run: |
pip install conan
- name: Run tests - Conan latest / Python 3.8
run: |
pytest -v tests
run: pip install conan

- name: Run tests - Conan latest / Python 3.9
run: pytest -v tests

- name: Install Conan develop
run: |
pip install git+https://github.com/conan-io/conan.git@develop2
- name: Run tests - Conan develop / Python 3.8
run: |
pytest -v tests
run: pip install git+https://github.com/conan-io/conan.git@develop2

- name: Run tests - Conan develop / Python 3.9
run: pytest -v tests

conan_windows:
runs-on: windows-latest
Expand All @@ -40,11 +93,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies and Conan latest
run: |
pip install -U pip
pip install pytest conan
- name: Run Windows-specific tests - Conan latest / Python 3.8
run: |
pytest -v -m win32 tests
- name: Run Windows-specific tests - Conan latest / Python 3.9
run: pytest -v -m win32 tests
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,9 @@ dmypy.json
tests/credentials.py
tmp*/*
.idea/*
demos/build-info/liba
demos/build-info/mypkg
demos/build-info/.conanrc
**/.conan_home/**
demos/build-info/*.json
demos/build-info/*.sh
104 changes: 104 additions & 0 deletions demos/build-info/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Using Build Info with Conan
===========================

Demo Pre-Requisites
-------------------

Have an Artifactory instance running (needs a version with API support, Artifactory
Community Edition won't work for this) with at least one repository called ``develop``.

To test the Relase Bundles generation you also need a [signing key already
created](https://jfrog.com/help/r/jfrog-artifactory-documentation/setting-up-rsa-keys-pairs)
in Artifactory.

To easily run an Artifactory in Docker:

```
docker run --name artifactory -d -e JF_SHARED_DATABASE_TYPE=derby -e JF_SHARED_DATABASE_ALLOWNONPOSTGRESQL=true -p 8081:8081 -p 8082:8082 releases-docker.jfrog.io/jfrog/artifactory-pro:latest
```

To test, you need to have the extensions installed:

```
conan config install https://github.com/conan-io/conan-extensions.git
```

We will create a BuildInfo with ``build_name=<Release/Debug>_build`` ``build_number=1``
and then create an aggregated Build Info for both Release and Debug configurations

``mypkg`` depending on ``liba``.

Two paralell jobs creating Release and Debug, each one with a BuildInfo, then aggregate
them

![Alt build](diagram.png?raw=true)

Running the demo
----------------

```

# Add the repos if you haven't already

conan remote add develop http://localhost:8081/artifactory/api/conan/develop
conan remote login develop admin -p password

# Also configure the server for the Build Info command

conan art:server add myartifactory http://localhost:8081/artifactory --user=admin --password=password

# Also you need to have the packages ready for creation:

conan new cmake_lib -d name=liba -d version=1.0 -o=liba
conan new cmake_lib -d name=mypkg -d version=1.0 -o=mypkg -d requires="liba/1.0"

# Start from a clean state

conan remove "*" -r=develop -c
conan remove "liba*" -c
conan remove "mypkg*" -c

# We create liba before building mypkg

conan create liba -s build_type=Release -tf=""
conan create liba -s build_type=Debug -tf=""
conan upload "liba*" -r=develop -c

# Release CI JOB

# build mypkg Release

conan create mypkg --format=json -s build_type=Release --build="mypkg*" -r=develop -tf="" > create_release.json
conan upload "mypkg*" -r=develop -c

# create the Build Info for Release and set the properties to the Artifacts in Artifactory

conan art:build-info create create_release.json release_build 1 develop --server=myartifactory --with-dependencies > release_build.json

# Upload the Build Info

conan art:build-info upload release_build.json --server=myartifactory

# Debug CI JOB

# build mypkg Debug, will pick liba from Artifactory

conan create mypkg --format=json -s build_type=Debug --build="mypkg*" -r=develop -tf="" > create_debug.json

conan upload "mypkg*" -r=develop -c

# create the Build Info for Debug and set the properties to the Artifacts in Artifactory

conan art:build-info create create_debug.json debug_build 1 develop --server=myartifactory --with-dependencies > debug_build.json

# Upload the Build Info

conan art:build-info upload debug_build.json --server=myartifactory

# Bundles aggregating both Release and Debug Builds

conan art:build-info bundle-create aggregated_bundle 1.0 test_key_pair --server=myartifactory --build-info=debug_build,1 --build-info=release_build,1

# You can delete the bundle
conan art:build-info bundle-delete aggregated_bundle 1.0 --server=myartifactory
```
Binary file added demos/build-info/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion extensions/commands/art/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ These are commands to manage certain Artifactory features:
- [``conan art:build-info``](readme_build_info.md): Manages JFrog Build Info (https://www.buildinfo.org/).
- ``append``
- ``create``
- ``create-bundle``
- ``bundle-create``
- ``bundle-delete``
- ``delete``
- ``get``
- ``promote``
Expand Down
Loading
Loading
0