Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-gauthier-geosiris committed Apr 3, 2024
1 parent 7a9f023 commit 8074c0d
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .github/actions/prepare-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
##
## Copyright (c) 2022-2023 Geosiris.
## SPDX-License-Identifier: Apache-2.0
##
---

name: Prepare Python and Poetry
Description: Install Python, Poetry and dev dependencies, cached for speed

inputs:
python-version:
description: 'Python version to use'
required: true
default: '3.x'

runs:
using: "composite"
steps:
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Load cached Poetry installation
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-4 # increment to reset cache

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: false

- name: Install Poetry Plugins
run: |
python -m pip install --upgrade pip
pip install poetry-dynamic-versioning
shell: bash
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-1

- name: Install dependencies and library
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
shell: bash

- name: Install Poetry Plugins
run: poetry self add "poetry-dynamic-versioning[plugin]"
shell: bash
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2023 GEOSIRIS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
112 changes: 112 additions & 0 deletions energyml-utils/.github/workflow/ci-energyml-utils-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
##
## Copyright (c) 2023-2024 Geosiris.
## SPDX-License-Identifier: Apache-2.0
##
---

name: Publish (pypiTest)

on:
push:
branches:
- main
pull_request:

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install poetry
uses: ../.github/actions/prepare-poetry
with:
python-version: 3.9

- name: Build
run: |
poetry install
poetry self add "poetry-dynamic-versioning[plugin]"
poetry build
- name: Save build artifacts
uses: actions/upload-artifact@v2
with:
name: dist-artifact
path: dist/

test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:

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

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v3
with:
name: dist-artifact
path: dist/

- name: Install from build
run: |
python -m pip install --upgrade pip
pip install pytest-mock
pip install etpproto --pre --target=dist --find-links=dist/
- name: Copy tests and example data to dist folder for testing against artifacts
run: |
cp -R tests dist/
# cp -R example_data dist/

- name: Run tests
run: pytest dist/tests

publish:
name: Publish to PyPI
needs: [build, test]
runs-on: ubuntu-latest
steps:

# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v3
with:
name: dist-artifact
path: dist/

- name: Install poetry
uses: ../.github/actions/prepare-poetry
with:
python-version: 3.9

- name: Upload to PyPI TEST
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi ${{ secrets.POETRY_PYPI_TEST_TOKEN_VALUE }}
poetry publish --repository test-pypi
2 changes: 1 addition & 1 deletion energyml-utils/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 GEOSIRIS
Copyright 2023 GEOSIRIS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 8074c0d

Please sign in to comment.