Skip to content

Commit

Permalink
Create composite action (#14)
Browse files Browse the repository at this point in the history
Minimise duplication
  • Loading branch information
tegataiprime authored Jun 28, 2023
1 parent 6ee889a commit 0aed209
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 77 deletions.
50 changes: 50 additions & 0 deletions .github/actions/poetry-initialize-action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Initilize Poetry'
description: 'Prepare a Virtual Environment for the Workflow'
inputs:
python-version:
description: "Version of Python to install"
required: true
deafult: '3.10'
outputs:
cache-hit:
description: "Using Cached Dependencies"
value: ${{ steps.cached-poetry-dependencies.outputs.cache-hit }}
runs:
using: "composite"
steps:
#-----------------------------------------------
# Install Python
#-----------------------------------------------
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

#----------------------------------------------
# Install & Configure Poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# Load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

#----------------------------------------------
# Install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
shell: bash
42 changes: 6 additions & 36 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
# Check-out Repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.10'

#----------------------------------------------
# ----- install & configure poetry -----
# Initilize Build Environment
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Initialize Build Environment
uses: ./.github/actions/poetry-initialize-action
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction
python-version: '3.10'

#----------------------------------------------
# create release
# Create Release
#----------------------------------------------
- name: Build project for distribution
run: poetry build
Expand Down
50 changes: 10 additions & 40 deletions .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,29 @@ jobs:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
# Check-out Repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.10'

#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true


#----------------------------------------------
# load cached venv if cache exists
# Initilize Build Environment
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
- name: Initialize Build Environment
uses: ./.github/actions/poetry-initialize-action
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction
python-version: '3.10'

#----------------------------------------------
# run linter
# Check for Lint
#----------------------------------------------
- name: Run Linter
run: |
source .venv/bin/activate
poetry run pylint --fail-under=9 src/
#----------------------------------------------
# run test suite
# Run Test Suite
#----------------------------------------------
- name: Run Unit Tests
run: |
Expand All @@ -91,7 +61,7 @@ jobs:
retention-days: 7

#----------------------------------------------
# perform static analysis
# Perform Static Code Analysis
#----------------------------------------------
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
Expand All @@ -100,7 +70,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

#----------------------------------------------
# check quality gate
# Check Quality Gate
#----------------------------------------------
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iracing-client"
version = "0.1.1-alpha"
version = "0.1.2a0"
description = ""
authors = ["James Carter <tegatai@gmail.com>"]
readme = "README.md"
Expand Down

0 comments on commit 0aed209

Please sign in to comment.