Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/actions/create-build-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: create-build-tag

outputs:
build_tag:
description: 'The generated build tag'
value: ${{ steps.create-build-tag.outputs.build_tag }}
runs:
using: "composite"
steps:
- name: Create build tag
id: create-build-tag
env:
# head_ref is available when a pull request triggers workflow, ref_name contains branch name outside of pull requests
BRANCH_NAME_RAW: ${{ github.head_ref || github.ref_name }}
COMMIT_SHA_RAW: ${{ github.sha }}
run: |
DATETIME=`date -u +"%Y-%m-%dT%H-%M-%S"`
BRANCH_NAME=`echo "${BRANCH_NAME_RAW}" | cut -c1-20 | sed 's|/|-|g'`
COMMIT_SHA=`echo "${COMMIT_SHA_RAW}" | cut -c 1-7`
echo "build_tag=${BRANCH_NAME}-${DATETIME}-${COMMIT_SHA}" >> "$GITHUB_OUTPUT"
shell: bash
70 changes: 70 additions & 0 deletions .github/actions/setup-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: Java & Gradle Setup
description: Setup runtime

inputs:
java_version:
description: 'The Java version to install.'
required: false
default: '25'
gradle_version:
description: 'The Gradle version to install. It do not force using this gradle version in other workflow steps, normally the installed gradle version of the project will be used.'
required: false
default: '9.1.0'
fetch-depth:
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
default: '1'
enable_caching:
description: 'If build and configuration caching should be enabled or disabled.'
default: 'true'
enable_daemon:
description: 'If build should be done using a separate gradle daemon.'
default: 'false'

runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
fetch-depth: ${{ inputs.fetch-depth }}

- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # 5.6.0
with:
java-version: ${{ inputs.java_version }}
distribution: 'zulu'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs to become temurin. Double check this.


- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # 6.2.0
with:
gradle-version: ${{ inputs.gradle_version }}

- name: Cache Gradle
if: ${{ inputs.enable_caching == 'true' }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/settings.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Configure Gradle properties
shell: bash
env:
CACHING: ${{ inputs.enable_caching }}
DAEMON: ${{ inputs.enable_daemon }}
run: |
set -euo pipefail
mkdir -p ~/.gradle
{
echo "ci=true"
echo "org.gradle.caching=${CACHING}"
echo "org.gradle.configuration-cache=${CACHING}"
echo "org.gradle.daemon=${DAEMON}"
} >> ~/.gradle/gradle.properties
78 changes: 78 additions & 0 deletions .github/workflows/java-gradle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: Java CI with Gradle for library

on:
push:
workflow_dispatch:
inputs:
local_image_tag:
description: Local image tag used before push
required: false
type: string
default: application:0.0.1-SNAPSHOT
deploy_branch:
description: Branch required to push image
required: false
type: string
default: main

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

jobs:
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
permissions:
id-token: write # Needed to load credentials
contents: read # Needed to read repository (content)
outputs:
build_tag: ${{ steps.create_tag.outputs.build_tag }}
environment:
name: ci
env:
LOCAL_IMAGE_TAG: ${{ inputs.local_image_tag }}
DEPLOY_BRANCH: ${{ inputs.deploy_branch }}
IMAGE_REPOSITORY_PREFIX: ${{ inputs.image_repository_prefix }}${{ inputs.namespace }}
IS_TAG: ${{ github.ref_type == 'tag' }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
fetch-depth: 1
persist-credentials: false

- name: Setup runtime
uses: ./.github/actions/setup-runtime

- name: Cache Gradle
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }}

- name: Optimize Gradle
shell: bash
run: |
mkdir -p ~/.gradle
echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties
echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties

- name: Build & Run Tests
run: ./gradlew build --configuration-cache

- name: Create Build Tag
id: create_tag
uses: ./.github/actions/create-build-tag

- name: Repository Name
id: repo
shell: bash
run: |
echo "name=${GITHUB_REPOSITORY#*/}" >> "$GITHUB_OUTPUT"
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ SPDX-License-Identifier: MPL-2.0

[![Power Grid Model logo](https://raw.githubusercontent.com/PowerGridModel/.github/main/artwork/svg/color.svg)](#)

# Power Grid Model template repository
# libpower-grid-model-java

## Usage

The PGM methods are available through class `org.lfenergy.pgm.PowerGridModelC`. The method names are identical to the method names in the C-documentation.

To load the native library there are two options:
- on supported architectures, the library can be autoloaded using `PGMLoader.autoload()`
- on other architecture, you can build and load the library yourself using `System.load(...)`, and verify if you've loaded it correctly using `PGMLoader.check()`.

## Supported architectures

- macOS ARM64
- macOS x86-64
- Linux ARM64
- Linux x86-64
- Windows x86-64

This is a template repository for the Power Grid Model project.
Only common and mandatory content is included in this repository.
The derived repositories should review and edit content relevant to the best practices and standards.

## Checklist after creating a repository from this template

Update the following items manually before publishing your repository:

- [ ] Rename the repository and update all references in this file.
- [ ] Replace all `pgm-template-repo` references across the repository, especially in this README and REUSE.toml.
- [ ] Replace the project title and description in this README.
- [ ] Ensure all third-party licenses are present in [LICENSES](https://github.com/PowerGridModel/pgm-template-repo/tree/main/LICENSES).
- [x] Rename the repository and update all references in this file.
- [x] Replace all `pgm-template-repo` references across the repository, especially in this README and REUSE.toml.
- [x] Replace the project title and description in this README.
- [ ] Ensure all third-party licenses are present in [LICENSES](https://github.com/PowerGridModel/libpower-grid-model-java/tree/main/LICENSES).

### Optional checks

Expand All @@ -28,22 +41,22 @@ Change these if applicable.
- [ ] Replace Power Grid Model project-specific links (for example contributing, support, release, security, and code of conduct links)
with links for your project.
- [ ] Add logos and badges corresponding to relevant pages
- [ ] Verify [LICENSE](https://github.com/PowerGridModel/pgm-template-repo/blob/main/LICENSE) copyright holder and year(s).
- [ ] Verify [LICENSE](https://github.com/PowerGridModel/libpower-grid-model-java/blob/main/LICENSE) copyright holder and year(s).
Also verify SPDX copyright headers in source and documentation files.
- [ ] Include documents present in [Home page of PGM org](https://github.com/PowerGridModel/.github/) in documentation if they are created.

## License

This project is licensed under the Mozilla Public License, version 2.0 - see
[LICENSE](https://github.com/PowerGridModel/pgm-template-repo/blob/main/LICENSE) for details.
[LICENSE](https://github.com/PowerGridModel/libpower-grid-model-java/blob/main/LICENSE) for details.

## Licenses third-party libraries

This project includes third-party libraries,
which are licensed under their own respective Open-Source licenses.
SPDX-License-Identifier headers are used to show which license is applicable.
The concerning license files can be found in the
[LICENSES](https://github.com/PowerGridModel/pgm-template-repo/tree/main/LICENSES) directory.
[LICENSES](https://github.com/PowerGridModel/libpower-grid-model-java/tree/main/LICENSES) directory.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# SPDX-License-Identifier: MPL-2.0

version = 1
SPDX-PackageName = "pgm-template-repo"
SPDX-PackageName = "libpower-grid-model-java"
SPDX-PackageSupplier = "Power Grid Model project <powergridmodel@lfenergy.org>"
SPDX-PackageDownloadLocation = "https://github.com/PowerGridModel/pgm-template-repo"
SPDX-PackageDownloadLocation = "https://github.com/PowerGridModel/libpower-grid-model-java"

[[annotations]]
path = "./**"
Expand Down
Loading
Loading