Skip to content

Commit

Permalink
pass image in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Oct 9, 2023
1 parent 21ebb5f commit 093181d
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 54 deletions.
2 changes: 0 additions & 2 deletions .github/scripts/collect-test-robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ git config --global --add safe.directory $PWD

echo "########################### Install Robot Framework ###########################"
cd tests
pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil

if [ "$distrib" = "ALMALINUX" ]; then
dnf groupinstall -y "Development Tools"
Expand All @@ -84,7 +83,6 @@ else
apt-get install -y python3-dev
fi

pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3

echo "########################## Install centreon collect ###########################"
cd ..
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/package-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ jobs:
fail-fast: false
matrix:
include:
- image: centreon-collect-alma8
distrib: el8
package_extension: rpm
runner: collect
arch: amd64
# - image: centreon-collect-alma8
# distrib: el8
# package_extension: rpm
# runner: collect
# arch: amd64
- image: centreon-collect-alma9
distrib: el9
package_extension: rpm
runner: collect
arch: amd64
- image: centreon-collect-debian-bullseye
distrib: bullseye
package_extension: deb
runner: collect
arch: amd64
- image: centreon-collect-debian-bullseye-arm64
distrib: bullseye
package_extension: deb
runner: collect-arm64
arch: arm64
# - image: centreon-collect-debian-bullseye
# distrib: bullseye
# package_extension: deb
# runner: collect
# arch: amd64
# - image: centreon-collect-debian-bullseye-arm64
# distrib: bullseye
# package_extension: deb
# runner: collect-arm64
# arch: arm64

runs-on: ${{ fromJson(format('["self-hosted", "{0}"]', matrix.runner)) }}

Expand Down
38 changes: 21 additions & 17 deletions .github/workflows/robot-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ jobs:

package:
needs: [get-version]
uses: ./.github/workflows/package-collect.yml
with:
version: ${{ needs.get-version.outputs.version }}.${{ needs.get-version.outputs.patch }}
img_version: ${{ needs.get-version.outputs.img_version }}
release: ${{ needs.get-version.outputs.release }}
commit_hash: ${{ github.sha }}
secrets: inherit
# uses: ./.github/workflows/package-collect.yml
runs-on: ubuntu-22.04
steps:
- run: |
echo fdsdfsdf
# with:
# version: ${{ needs.get-version.outputs.version }}.${{ needs.get-version.outputs.patch }}
# img_version: ${{ needs.get-version.outputs.img_version }}
# release: ${{ needs.get-version.outputs.release }}
# commit_hash: ${{ github.sha }}
# secrets: inherit

robot-test:
needs: [get-version, package]
Expand All @@ -54,16 +58,16 @@ jobs:
package_extension: rpm
arch: amd64
database_type: mariadb
- distrib: el9
image: centreon-collect-mysql-alma9-test
package_extension: rpm
arch: amd64
database_type: mysql
- distrib: bullseye
image: centreon-collect-debian-bullseye-arm64-test
package_extension: deb
arch: arm64
database_type: mariadb
# - distrib: el9
# image: centreon-collect-mysql-alma9-test
# package_extension: rpm
# arch: amd64
# database_type: mysql
# - distrib: bullseye
# image: centreon-collect-debian-bullseye-arm64-test
# package_extension: deb
# arch: arm64
# database_type: mariadb
name: robot test ${{ matrix.database_type }} ${{ matrix.distrib }} ${{ matrix.arch }}

uses: ./.github/workflows/robot-test.yml
Expand Down
86 changes: 66 additions & 20 deletions .github/workflows/robot-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,40 @@ jobs:
load-test-image:
runs-on: ubuntu-22.04
steps:
- name: Pull image
run: |
docker image pull ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}:latest

save-image-in-cache:
runs-on: ubuntu-22.04
steps:
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.registry_username }}
password: ${{ secrets.registry_password }}

- name: Login to Proxy Registry
uses: docker/login-action@v2
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.registry_username }}
password: ${{ secrets.registry_password }}


- name: Download image
run: |
docker save --output /tmp/${{inputs.image}} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}:${{ inputs.image_version }}
docker pull ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}
shell: bash

- name: compress image
- name: Image to disk
run: |
7z a /tmp/${{inputs.image}}.7z /tmp/${{inputs.image}}
docker save --output /tmp/${{inputs.image}} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}:latest
shell: bash

- name: cache compressed image
- name: image to cache
uses: actions/cache/save@v3
with:
path: /tmp/${{inputs.image}}.7z
path: /tmp/${{inputs.image}}
key: ${{inputs.image}}

robot-test-list:
needs: [load-test-image]
runs-on: ubuntu-22.04
outputs:
features: ${{ steps.list-features.outputs.features }}
Expand All @@ -78,12 +88,12 @@ jobs:
robot-test:
needs: [robot-test-list]
runs-on: ${{ contains(inputs.image, 'arm') && fromJson('["self-hosted", "collect-arm64"]') || 'ubuntu-22.04' }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}:latest
options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
credentials:
username: ${{ secrets.registry_username }}
password: ${{ secrets.registry_password }}
# container:
# image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}:latest
# options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
# credentials:
# username: ${{ secrets.registry_username }}
# password: ${{ secrets.registry_password }}

strategy:
fail-fast: false
Expand All @@ -105,13 +115,49 @@ jobs:
key: ${{ inputs.package_cache_key }}
fail-on-cache-miss: true

- name: Restore image
uses: actions/cache@v3
with:
path: /tmp/${{inputs.image}}
key: ${{inputs.image}}
fail-on-cache-miss: true

- name: load image
run: |
docker load --input /tmp/${{inputs.image}}
# docker tag ${{inputs.image}} ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}}

#- name: Test ${{ matrix.feature }}
# run: bash ./.github/scripts/collect-test-robot.sh ${{ matrix.feature }} ${{inputs.database_type}}
# shell: bash
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.collect_s3_secret_key }}
# AWS_BUCKET: centreon-collect-robot-report

- name: Test1 ${{ matrix.feature }}
run: |
ls -al
- name: Test2 ${{ matrix.feature }}
run: |
echo $(pwd)
- name: Test ${{ matrix.feature }}
run: bash ./.github/scripts/collect-test-robot.sh ${{ matrix.feature }} ${{inputs.database_type}}
shell: bash
run: |
docker run --rm -v $(pwd):/test_collect \
--env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
--env AWS_BUCKET=centreon-collect-robot-report \
--workdir /test_collect \
${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{inputs.image}} \
ls -al
env:
AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.collect_s3_secret_key }}
AWS_BUCKET: centreon-collect-robot-report


- name: Move reports
if: ${{ !cancelled() }}
Expand Down

0 comments on commit 093181d

Please sign in to comment.