Skip to content

Fix: Broken workflow syntax (#67) #10

Fix: Broken workflow syntax (#67)

Fix: Broken workflow syntax (#67) #10

---
# 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:
python-version: "3.10"
artefacts: "dist"
### TESTS ###
jobs:
repository:
name: "Check Repository Content"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.python.outputs.matrixjson }}
python: ${{ steps.content.outputs.python }}
notebooks: ${{ steps.content.outputs.notebooks }}
steps:
- uses: actions/checkout@v4
- name: "Inspect Files"
id: 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
- name: "Extract Python Versioning"
id: python
if: ${{ steps.content.outputs.python == 'true' }}
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/python-versions-matrix@main
builds:
name: "Python Builds"
needs:
- repository
runs-on: "ubuntu-latest"
continue-on-error: true
# if: needs.repository.outputs.python == true
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.repository.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: "dist"
- name: "Validate Artefacts with Twine"
id: python-twine-check
with:
output-location: ${{ env.artefacts}}
uses: os-climate/devops-reusable-workflows/.github/actions/python-twine-check@main
test:
name: "Test: GitHub 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 current work: https://github.com/actions/checkout/issues/1471
fetch-tags: true
- name: "Action: latest-semantic-tag"
id: latest-semantic-tag
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/latest-semantic-tag@main
- name: "Action: increment-semantic-tag"
id: increment-semantic-tag
# yamllint disable-line rule:line-length
uses: os-climate/devops-reusable-workflows/.github/actions/increment-semantic-tag@main
with:
tag: "${{ steps.latest-semantic-tag.outputs.TAG }}"
type: "minor"