Skip to content

Commit

Permalink
Merge pull request #10 from shakenfist/github-actions
Browse files Browse the repository at this point in the history
Convert to github actions for CI.
  • Loading branch information
mikalstill committed Jan 11, 2023
2 parents dade632 + bb12fc9 commit b597adb
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 49 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Functional tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
functional:
runs-on: self-hosted
timeout-minutes: 120

# NOTE(mikal): git repos are checked out to /srv/github/_work/{repo}/{repo}
# which is available as GITHUB_WORKSPACE. You can find other environment
# variables at https://docs.github.com/en/actions/learn-github-actions/environment-variables

steps:
- name: Remove previous unfinished runs
uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get rid of sudo error messages
run: |
hostname=$(cat /etc/hostname)
sudo chmod ugo+rw /etc/hosts
echo "127.0.1.1 $hostname" >> /etc/hosts
- name: Install minimum dependencies
run: |
echo 'Acquire::http::Proxy "http://192.168.1.50:8000";' > /tmp/00proxy
sudo mv /tmp/00proxy /etc/apt/apt.conf.d/
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install -y python3 python3-dev python3-pip python3-wheel apparmor docker.io runc
sudo systemctl restart apparmor
- name: Log docker setup
run: |
sudo chown debian.debian /var/run/docker.sock
echo "/var/run/docker.sock:"
sudo ls -l /var/run/docker.sock
- name: Checkout occystrap
uses: actions/checkout@v3
with:
path: occystrap
fetch-depth: 0

- name: Build occystrap wheel and install it
run: |
cd /srv/github/_work/occystrap/occystrap/occystrap
rm -f dist/*
python3 setup.py sdist bdist_wheel
pip3 install dist/occystrap*.whl
- name: Run a local docker registry to talk to, and populate it with test data
run: |
docker run -d -p 5000:5000 --restart=always --name registry registry:2
cd /srv/github/_work/occystrap/occystrap/occystrap/deploy/occystrap_ci/testdata
for img in deletion_layers; do
cd $img
docker build -t localhost:5000/occystrap_$img:latest .
docker push localhost:5000/occystrap_$img:latest
cd /srv/github/_work/occystrap/occystrap/occystrap/deploy/occystrap_ci/testdata
done
- name: Run functional tests
run: |
cd /srv/github/_work/occystrap/occystrap/occystrap/deploy
sudo pip3 install -r requirements.txt
sudo pip3 install -r test-requirements.txt
stestr run --concurrency=5
39 changes: 0 additions & 39 deletions Jenkinsfile-debian-11-none

This file was deleted.

4 changes: 2 additions & 2 deletions occystrap/docker_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def fetch(self, fetch_callback=always_fetch):
layer_filename = layer['digest'].split(':')[1]
if not fetch_callback(layer_filename):
LOG.info('Fetch callback says skip layer %s' % layer['digest'])
yield(constants.IMAGE_LAYER, layer_filename, None)
yield (constants.IMAGE_LAYER, layer_filename, None)
continue

LOG.info('Fetching layer %s (%d bytes)'
Expand Down Expand Up @@ -184,7 +184,7 @@ def fetch(self, fetch_callback=always_fetch):
sys.exit(1)

with open(tf.name, 'rb') as f:
yield(constants.IMAGE_LAYER, layer_filename, f)
yield (constants.IMAGE_LAYER, layer_filename, f)

finally:
os.unlink(tf.name)
Expand Down
2 changes: 1 addition & 1 deletion occystrap/output_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def fetch(self):

config_filename = manifest[0]['Config']
with open(os.path.join(self.path, config_filename), 'rb') as f:
yield(constants.CONFIG_FILE, config_filename, f)
yield (constants.CONFIG_FILE, config_filename, f)

for layer in manifest[0]['Layers']:
with open(os.path.join(self.path, layer), 'rb') as f:
Expand Down
5 changes: 0 additions & 5 deletions occystrap/output_tarfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import hashlib
import io
import json
import logging
import os
import re
import sys
import tarfile
import tempfile
import zlib

from occystrap import constants

Expand Down
2 changes: 1 addition & 1 deletion occystrap/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UnauthorizedException(Exception):
def get_user_agent():
try:
version = VersionInfo('occystrap').version_string()
except:
except Exception:
version = '0.0.0'
return 'Mozilla/5.0 (Ubuntu; Linux x86_64) Occy Strap/%s' % version

Expand Down
2 changes: 1 addition & 1 deletion tools/flake8wrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
diff -u --from-file /dev/null ${files} | $FLAKE_COMMAND --diff "$@"
diff -u --from-file /dev/null ${files} | $FLAKE_COMMAND "$@"
else
echo "Running flake8 on all files"
exec $FLAKE_COMMAND "$@"
Expand Down

0 comments on commit b597adb

Please sign in to comment.