Skip to content

Commit

Permalink
Merge pull request #2 from pypsa-meets-earth/main
Browse files Browse the repository at this point in the history
Merge from Upstream
  • Loading branch information
GbotemiB authored Dec 6, 2024
2 parents bc4e8fb + d727d39 commit 52e5fce
Show file tree
Hide file tree
Showing 41 changed files with 2,823 additions and 1,340 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# dependabot
# Ref: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
# ------------------------------------------------------------------------------
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
groups:
# open a single pull-request for all GitHub actions updates
github-actions:
patterns:
- '*'
92 changes: 92 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
schedule:
- cron: '23 18 * * 5'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
on:
push:
branches:
- main
schedule:
- cron: "0 5 * * 0"

jobs:
contrib-readme-job:
runs-on: ubuntu-latest
name: A job to automate contrib in readme
steps:
- name: Contribute List
uses: akhilmhdh/[email protected].6
uses: akhilmhdh/[email protected].10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 33 additions & 14 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Test workflows

on:
push:
Expand All @@ -10,35 +10,43 @@ on:
schedule:
- cron: "0 5 * * TUE"

# Cancel any in-progress runs when a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CACHE_NUMBER: 2 # Change this value to manually reset the environment cache
CACHE_NUMBER: 0 # Change this value to manually reset the environment cache

jobs:
build:
run-tests:
name: OS
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest

runs-on: ${{ matrix.os }}
os: [ubuntu, macos] #, windows]
include:
- os: ubuntu
env_file: envs/linux-pinned.yaml
- os: macos
env_file: envs/macos-pinned.yaml
# - os: windows
# env_file: envs/windows-pinned.yaml

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4


- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: '1.5.9-1'
environment-file: envs/environment.yaml
environment-file: ${{ matrix.env_file }}
log-level: debug
init-shell: bash
cache-environment: true
Expand All @@ -50,7 +58,7 @@ jobs:
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV
- name: Cache data and cutouts folders
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
data
Expand All @@ -64,6 +72,17 @@ jobs:
- name: Run Test
run: make test

- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.os }}
path: |
logs
.snakemake/log
results
retention-days: 3

# - name: Test plotting and summaries
# run: |
# snakemake --cores all plot_all_p_nom
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/update-pinned-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Update pinned envs

on:
push:
paths:
- envs/environment.yaml
# Run every Sunday at 5:00 UTC
schedule:
- cron: "0 5 * * 0"
workflow_dispatch:


jobs:
update-pinned-environment:
if: ${{ github.ref == 'refs/heads/main' }}
name: Update pinned envs
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
include:
- os: ubuntu
suffix: "linux"
- os: macos
suffix: "macos"
- os: windows
suffix: "windows"

steps:
- uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ${{ github.event.repository.name }}
environment-file: envs/environment.yaml

- name: Update pinned environment per OS
run: |
conda env export --name ${{ github.event.repository.name }} --no-builds > envs/${{ matrix.suffix }}-pinned.yaml
- name: Add SPDX header
if: ${{ matrix.suffix != 'windows' }}
run: |
SPDX_HEADER="# SPDX-FileCopyrightText: PyPSA-Earth and PyPSA-Eur Authors\n#\n# SPDX-License-Identifier: CC0-1.0\n"
echo -e "$SPDX_HEADER" | cat - envs/${{ matrix.suffix }}-pinned.yaml > temp && mv temp envs/${{ matrix.suffix }}-pinned.yaml
- name: Add SPDX header (windows)
if: ${{ matrix.suffix == 'windows' }}
run: |
$SPDX_HEADER = "# SPDX-FileCopyrightText: PyPSA-Earth and PyPSA-Eur`r`n#`r`n# SPDX-License-Identifier: CC0-1.0`r`n`r`n"
$CurrentContent = Get-Content "envs/${{ matrix.suffix }}-pinned.yaml" -Raw
$NewContent = $SPDX_HEADER + $CurrentContent
$NewContent | Set-Content "envs/${{ matrix.suffix }}-pinned.yaml"
- name: Cache environment files
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.suffix }}-pinned
path: envs/${{ matrix.suffix }}-pinned.yaml

create-pull-request:
needs: update-pinned-environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Prepare files for commit
run: |
mkdir -p envs
mv linux-pinned/* envs/linux-pinned.yaml
mv macos-pinned/* envs/macos-pinned.yaml
mv windows-pinned/* envs/windows-pinned.yaml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-pinned-environment
title: "[github-actions.ci] Update pinned envs"
body: "Automatically generated PR to update pinned environment files for Windows, macOS, and Linux."
commit-message: "Update pinned environment files for all platforms"
17 changes: 10 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ repos:
types_or: [python, rst, markdown]
files: ^(scripts|doc)/

# Make docstrings PEP 257 compliant
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
# # Make docstrings PEP 257 compliant
# - repo: https://github.com/PyCQA/docformatter
# rev: v1.7.5
# hooks:
# - id: docformatter
# args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
# entry: docformatter
# language: python
# types: [python]

- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
Expand Down Expand Up @@ -87,6 +90,6 @@ repos:

# Check for FSFE REUSE compliance (licensing)
- repo: https://github.com/fsfe/reuse-tool
rev: v4.0.3
rev: v5.0.2
hooks:
- id: reuse
Loading

0 comments on commit 52e5fce

Please sign in to comment.