Skip to content

Commit

Permalink
Deploy discover data (#485)
Browse files Browse the repository at this point in the history
- This PR adds automatic deployment of leapp discover --json output to the 
  https://github.com/oamg/githubio-data repository after successful test runs and only when 
  merged to master

  Please note on pull requests the deployment section won't actually run as it has a condition for 
  push to master only.

- Additionally fixes some config warning from travis.

Signed-off-by: Vinzenz Feenstra <[email protected]>
  • Loading branch information
vinzenz authored Apr 30, 2020
1 parent a1b3b75 commit c74dd1b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
24 changes: 16 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
git:
depth: 3
language:
minimal
language: shell
os: linux
dist: xenial
env:
global:
- CONTAINER=centos:7
jobs:
- PYTHON_VENV=python2.7
- PYTHON_VENV=python3.6
services:
- docker
sudo: required

install:
- docker pull ${CONTAINER}
- docker build -t leapp-tests -f utils/docker-tests/Dockerfile utils/docker-tests

script:
- docker run --rm -ti -v ${PWD}:/payload --env=PYTHON_VENV leapp-tests
jobs:
include:
- script:
- docker run --rm -ti -v ${PWD}:/payload --env=PYTHON_VENV leapp-tests
env: PYTHON_VENV=python2.7
- script:
- docker run --rm -ti -v ${PWD}:/payload --env=PYTHON_VENV leapp-tests
env: PYTHON_VENV=python3.6
- stage: deploy
script:
- docker run --rm -ti -v ${PWD}:/payload --entrypoint "/bin/bash" leapp-tests -c "make install-deps && make dashboard_data"
- bash ./utils/update_dashboard.sh
if: branch = master AND type = push
Binary file added .travis/githubio-data-idrsa
Binary file not shown.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,11 @@ test_no_lint:
test: lint test_no_lint
dashboard_data:
. tut/bin/activate; \
snactor repo find --path repos/; \
pushd repos/system_upgrade/el7toel8/; \
python ../../../utils/dashboard-json-dump.py > ../../../discover.json; \
popd
.PHONY: help build clean prepare source srpm copr_build print_release register install-deps lint test_no_lint test
.PHONY: help build clean prepare source srpm copr_build print_release register install-deps lint test_no_lint test dashboard_data
15 changes: 15 additions & 0 deletions utils/dashboard-json-dump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import print_function
import json

from leapp.utils.repository import find_repository_basedir
from leapp.repository.scan import find_and_scan_repositories

base_dir = find_repository_basedir('.')
repository = find_and_scan_repositories(base_dir, include_locals=True)

repository.load()

if not hasattr(repository, 'repos'):
repository.repos = [repository]

print(json.dumps([repo.serialize() for repo in repository.repos]))
29 changes: 29 additions & 0 deletions utils/update_dashboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Decrypt private SSH key
ENCRYPTED_FILE=.travis/githubio-data-idrsa
DECRYPTED_FILE=${ENCRYPTED_FILE}-dec
openssl aes-256-cbc -K $aes_encryption_key -iv $aes_encryption_iv -in $ENCRYPTED_FILE -out $DECRYPTED_FILE -d

# Setup SSH agent with decrypted private SSH key
eval "$(ssh-agent -s)"
chmod 0600 $DECRYPTED_FILE
ssh-add $DECRYPTED_FILE

# Clone githubio-data repository
git clone --depth 1 --branch master [email protected]:oamg/githubio-data

cd githubio-data
# Setting username and email for committer
git config user.name "Leapp Build Automation"
git config user.email "[email protected]"

# Update data
mv -f ../discover.json files/discover.json

# Stage and commit
git add files/discover.json
git commit -s -m "Leapp dashboard discover for ${TRAVIS_COMMIT}" --allow-empty

# Push changes
git push origin master

0 comments on commit c74dd1b

Please sign in to comment.