Skip to content

Commit

Permalink
Merge pull request #1 from Laurynas-Jagutis/feature/single-pr-workflow
Browse files Browse the repository at this point in the history
Setup for a single PR workflow
  • Loading branch information
Laurynas-Jagutis authored Feb 26, 2025
2 parents b0b37ad + f57440f commit 1cb1788
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ name: Build and Test C++ and Python

# Controls when the workflow will run
on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:
inputs:
Expand All @@ -35,9 +27,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-main
cancel-in-progress: true


jobs:

acquire-python-version-build-sdist:
name: Build sdist and set version
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -306,20 +296,20 @@ jobs:
- name: Display tag
run: echo "${{ steps.tag.outputs.tag }}"

- name: Upload wheels
if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (inputs.create_release == 'true'))
run: |
pip install twine
echo "Publish to PyPI..."
twine upload --verbose wheelhouse/*
- name: Release
uses: softprops/action-gh-release@v2
if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (inputs.create_release == 'true'))
with:
files: |
./wheelhouse/*
tag_name: ${{ steps.tag.outputs.tag }}
prerelease: ${{ github.ref != 'refs/heads/main'}}
generate_release_notes: true
target_commitish: ${{ github.sha }}
# - name: Upload wheels
# if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (inputs.create_release == 'true'))
# run: |
# pip install twine
# echo "Publish to PyPI..."
# twine upload --verbose wheelhouse/*

# - name: Release
# uses: softprops/action-gh-release@v2
# if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (inputs.create_release == 'true'))
# with:
# files: |
# ./wheelhouse/*
# tag_name: ${{ steps.tag.outputs.tag }}
# prerelease: ${{ github.ref != 'refs/heads/main'}}
# generate_release_notes: true
# target_commitish: ${{ github.sha }}
2 changes: 1 addition & 1 deletion .github/workflows/check-blocking-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: MPL-2.0


name: Check Blocking Labels

on:
Expand Down Expand Up @@ -44,3 +43,4 @@ jobs:
run: |
echo "This pull request needs (more) unit tests before it may be merged (needs-unit-tests)"
exit 3
8 changes: 0 additions & 8 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
name: Check Code Quality

on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:

Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: CI Build

# Controls when the workflow will run
on:
# run pipeline on push event of main branch.
push:
branches:
- main
# run pipeline on pull request.
pull_request:
# run pipeline on merge queue
merge_group:
# run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: "0 2 * * *" # Based on UTC time

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ci-build
cancel-in-progress: true

jobs:
build-test-release:
name: build-test-release
uses: "./.github/workflows/build-test-release.yml"
permissions:
contents: write
with:
create_release: false

check-code-quality:
uses: "./.github/workflows/check-code-quality.yml"

reuse-compliance:
uses: "./.github/workflows/reuse-compliance.yml"

clang-tidy:
uses: "./.github/workflows/clang-tidy.yml"
with:
target: "all power_grid_model_benchmark_cpp"

citations:
uses: "./.github/workflows/citations.yml"

sonar:
uses: "./.github/workflows/sonar.yml"
secrets: inherit
4 changes: 0 additions & 4 deletions .github/workflows/citations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
paths:
- CITATION.cff
- .github/workflows/citations.yml
pull_request:
paths:
- CITATION.cff
- .github/workflows/citations.yml
# run pipeline from another workflow
workflow_call:
# run this workflow manually from the Actions tab
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
name: Clang Tidy

on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:
inputs:
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/reuse-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
name: REUSE Compliance Check

on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:
# run this workflow manually from the Actions tab
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
name: Sonar Cloud

on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:
# run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-sonar
Expand Down Expand Up @@ -71,8 +67,8 @@ jobs:
sed -i -r "s/\s*branchesToCover\s*=\s*\"[0-9]+\"\s+coveredBranches\s*=\s*\"[0-9]+\"//g" cpp_coverage.xml
- name: Run sonar-scanner
# only run sonar server in push event or pull request event from own repo
if: ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'PowerGridModel') }}
# # only run sonar server in push event or pull request event from own repo
# if: ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'PowerGridModel') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: MPL-2.0
[![Downloads](https://static.pepy.tech/badge/power-grid-model)](https://pepy.tech/project/power-grid-model)
[![Downloads](https://static.pepy.tech/badge/power-grid-model/month)](https://pepy.tech/project/power-grid-model)

[![Build and Test C++ and Python](https://github.com/PowerGridModel/power-grid-model/actions/workflows/main.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/main.yml)
[![Build and Test C++ and Python](https://github.com/PowerGridModel/power-grid-model/actions/workflows/build-test-release.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/build-test-release.yml)
[![Check Code Quality](https://github.com/PowerGridModel/power-grid-model/actions/workflows/check-code-quality.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/check-code-quality.yml)
[![Clang Tidy](https://github.com/PowerGridModel/power-grid-model/actions/workflows/clang-tidy.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/clang-tidy.yml)
[![REUSE Compliance Check](https://github.com/PowerGridModel/power-grid-model/actions/workflows/reuse-compliance.yml/badge.svg)](https://github.com/PowerGridModel/power-grid-model/actions/workflows/reuse-compliance.yml)
Expand Down

0 comments on commit 1cb1788

Please sign in to comment.