Skip to content

Commit

Permalink
ci: migrate first CIs
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperDramsch committed Jan 10, 2025
1 parent f8e5b39 commit 2c59d0b
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/label-public-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Manage labels of pull requests that originate from forks
name: label-public-pr

on:
pull_request_target:
types: [opened, synchronize]

jobs:
label:
uses: ecmwf-actions/reusable-workflows/.github/workflows/label-pr.yml@v2
21 changes: 21 additions & 0 deletions .github/workflows/pr-conventional-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Ensure Conventional Commit in PR title"

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104 changes: 104 additions & 0 deletions .github/workflows/python-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Test PR

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- develop
schedule:
- cron: "9 2 * * 0" # at 9:02 on sunday

jobs:
quality:
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-precommit-run.yml@v2
with:
skip-hooks: "no-commit-to-branch"

checks:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install basic dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-md pytest-emoji
- name: Detect changed packages
id: changed-packages
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
echo "training_changed=$(echo "$CHANGED_FILES" | grep -q '^training/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "graphs_changed=$(echo "$CHANGED_FILES" | grep -q '^graphs/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "models_changed=$(echo "$CHANGED_FILES" | grep -q '^models/.*\.py$' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
- name: Install training package
run: |
if [[ ${{ steps.changed-packages.outputs.training_changed }} == 'true' ]]; then
echo "Installing training from local source"
pip install -e ./training[tests]
else
echo "Installing training from PyPI"
pip install anemoi-training[tests]
fi
- name: Install graphs package
run: |
if [[ ${{ steps.changed-packages.outputs.graphs_changed }} == 'true' ]]; then
echo "Installing graphs from local source"
pip install -e ./graphs[tests]
else
echo "Installing graphs from PyPI"
pip install anemoi-graphs[tests]
fi
- name: Install models package
run: |
if [[ ${{ steps.changed-packages.outputs.models_changed }} == 'true' ]]; then
echo "Installing models from local source"
pip install -e ./models[tests]
else
echo "Installing models from PyPI"
pip install anemoi-models[tests]
fi
- name: Run pytest for changed training package
if: steps.changed-packages.outputs.training_changed == 'true'
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
custom-pytest: pytest training/tests

- name: Run pytest for changed graphs package
if: steps.changed-packages.outputs.graphs_changed == 'true'
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
custom-pytest: pytest graphs/tests

- name: Run pytest for changed models package
if: steps.changed-packages.outputs.models_changed == 'true'
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
custom-pytest: pytest models/tests

- name: Run integration tests
if: success()
uses: ecmwf-actions/reusable-workflows/.github/workflows/qa-pytest-pyproject.yml@v2
with:
python-version: ${{ matrix.python-version }}
install-dependencies: false
12 changes: 12 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# (C) Copyright 2025 Anemoi contributors.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.


def test_dummy():
pass

0 comments on commit 2c59d0b

Please sign in to comment.