Skip to content

Commit

Permalink
Merge pull request #22 from oarepo/miroslavsimek/be-184-better-builde…
Browse files Browse the repository at this point in the history
…r-import-handling

Updated tests for the dependency tracking & updated omb
  • Loading branch information
mesemus authored Oct 30, 2023
2 parents 8c629b1 + 8e59498 commit 37501d3
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 94 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build and test

on:
workflow_call:
inputs:
oarepo:
description: OARepo version (11, 12, ...)
required: true
default: 11
type: string

env:
OAREPO_VERSION: ${{ github.event.inputs.oarepo }}

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v3
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Runs Opensearch
uses: ankane/setup-opensearch@v1
with:
plugins: analysis-icu

- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}

- name: Run tests
run: |
./run-tests.sh
- name: Build package to publish
run: |
.venv-builder/bin/python setup.py sdist bdist_wheel
# extra_content="$(tar -tf dist/*.tar.gz | sed 's#[^/]*/##' | grep '/' | grep -v oarepo_model_builder_tests)"
# test -z "$extra_content" || (echo "Unexpected content in dist tar.gz: $extra_content" && exit 1)
# extra_content="$(unzip -ql dist/*.whl | grep -v oarepo_model_builder_tests | tail -n +5)"
# test -z "$extra_content" || (echo "Unexpected content in dist whl: $extra_content" && exit 1)

- name: Freeze packages
run: |
.venv-builder/bin/pip freeze > requirements.txt
.venv-model/bin/pip freeze >>requirements.txt
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: requirements.txt
path: requirements.txt
89 changes: 0 additions & 89 deletions .github/workflows/main.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Dispatch

on:
workflow_dispatch:
inputs:
oarepo:
description: OARepo version (11, 12, ...)
required: true
default: 11

jobs:
build:
uses: ./.github/workflows/build.yaml
with:
oarepo: ${{ github.event.inputs.oarepo }}
36 changes: 36 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build, test and publish

on: push

permissions:
id-token: write
contents: read

jobs:
build:
uses: ./.github/workflows/build.yaml
with:
oarepo: 11

publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Use built artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: List files
run: |
ls -la
ls -la dist
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __pycache__/
.Python
env/
venv/
.venv/
.venv*/
build/
develop-eggs/
downloads/
Expand Down Expand Up @@ -88,6 +88,6 @@ example_model/
dist/
.vscode/

.model_venv
.venv-model
.venv-builder

25 changes: 23 additions & 2 deletions run_tests.sh → run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash
set -e

OAREPO_VERSION=${OAREPO_VERSION:-11}
OAREPO_VERSION_MAX=$((OAREPO_VERSION+1))

if [ -d .venv-builder ] ; then
rm -rf .venv-builder
fi

python3 -m venv .venv-builder
source .venv-builder/bin/activate
.venv-builder/bin/pip install -U setuptools pip wheel
.venv-builder/bin/pip install -e .


DIR="example_model"
#cd $(dirname $0)
if test -d $DIR; then
Expand All @@ -26,9 +40,16 @@ check_or_die $DIR/tests/test_service.py

echo "checking the test files are runnable"

python3 -m venv .model_venv
. .model_venv/bin/activate
deactivate

if [ -d .venv-model ] ; then
rm -rf .venv-model
fi

python3 -m venv .venv-model
. .venv-model/bin/activate
pip install -U setuptools pip wheel
pip install "oarepo>=$OAREPO_VERSION,<$OAREPO_VERSION_MAX"
pip install -e "$DIR/.[tests]"
python $DIR/tests/conftest.py
python $DIR/tests/test_resource.py
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder-tests
version = 4.0.5
version = 4.0.6
description =
authors = Ronald Krist <[email protected]>
readme = README.md
Expand Down

0 comments on commit 37501d3

Please sign in to comment.