Skip to content

Feat: Language identification step (#70) #13

Feat: Language identification step (#70)

Feat: Language identification step (#70) #13

---
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 The Linux Foundation <https://linuxfoundation.org>
name: "🧪 Test GitHub Actions/Workflows"
# yamllint disable-line rule:truthy
on:
workflow_dispatch:
push:
branches: [main, master]
# paths: [".github/actions/**", ".github/workflows/**"]
env:
default-python: "3.10"
artefacts: "dist"
### TESTS ###
jobs:
identify-content:
name: "Identify Content"
runs-on: ubuntu-latest
outputs:
python: ${{ steps.identify-content.outputs.python }}
notebooks: ${{ steps.identify-content.outputs.notebooks }}
steps:
- uses: actions/checkout@v4
- name: "Identify Content"
id: identify-content
run: |
# Inspect files in repository
# Check if repository contains a Python project
if [ -f pyproject.toml ]; then
echo "Python project metadata found"
echo "python=true" >> "$GITHUB_OUTPUT"
else
echo "python=false" >> "$GITHUB_OUTPUT"
fi
# Check if repository contains Jupyter Notebooks
NOTEBOOKS=$(find . -name '*.ipynb' | wc -l )
if [ "$NOTEBOOKS" -ne 0 ]; then
echo "Jupyter notebooks found"
echo "notebooks=true" >> "$GITHUB_OUTPUT"
else
echo "notebooks=false" >> "$GITHUB_OUTPUT"
fi
python-project:
name: "Python Project"
needs:
- identify-content
if: needs.identify-content.outputs.python == 'true'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.python.outputs.matrixjson }}
steps:
- uses: actions/checkout@v4
- name: "Extract Python Versioning"
id: python
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/python-versions-matrix@main
python-build:
name: "Python Build"
needs:
- python-project
runs-on: "ubuntu-latest"
continue-on-error: true
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.python-project.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "Setup PDM Build Tool"
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: "Build: Python Project"
id: python-project-build
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/python-project-build@main
with:
artefacts: ${{ env.artefacts}}
- name: "Validate Artefacts with Twine"
id: python-twine-check
with:
artefacts: ${{ env.artefacts}}
uses: os-climate/devops-reusable-workflows/.github/actions/python-twine-check@main
test:
name: "Validate Actions/Workflows"
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
# Does not currently work: https://github.com/actions/checkout/issues/1471
fetch-tags: true
# latest-semantic-tag currently contains a workaround for this behaviour
- name: "Action: semantic-tag-latest"
id: semantic-tag-latest
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/semantic-tag-latest@main
- name: "Action: semantic-tag-increment"
id: semantic-tag-increment
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/semantic-tag-increment@main
with:
tag: "${{ steps.semantic-tag-latest.outputs.TAG }}"
type: "minor"