Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prepare for Sonatype release #21

Merged
merged 8 commits into from
Feb 14, 2024
Merged
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
5 changes: 5 additions & 0 deletions .github/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: power-server
release:
current-version: 0.0.1
next-version: 0.0.2-SNAPSHOT

62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
pull_request:
types: [ closed ]
paths:
- '.github/project.yml'

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

defaults:
run:
shell: bash

jobs:
release:
runs-on: ubuntu-latest
name: Release power-server
if: ${{github.event.pull_request.merged == true}}

steps:
- uses: radcortez/project-metadata-action@main
name: Retrieve project metadata
id: metadata
with:
github-token: ${{secrets.GITHUB_TOKEN}}
metadata-file-path: '.github/project.yml'

- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Configure Git author
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Maven release ${{steps.metadata.outputs.current-version}}
run: |
git checkout -b release
mvn -B release:prepare -Prelease -Darguments="-DperformRelease -Dno-samples -DskipTests" -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}}
git checkout ${{github.base_ref}}
git rebase release
mvn -B release:perform -Darguments="-DperformRelease -Dno-samples -DskipTests" -DperformRelease -Prelease
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Push tags
run: git push && git push --tags
5 changes: 3 additions & 2 deletions build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
<parent>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>build-tools</artifactId>

<name>power-server : code formatting support</name>
<description>Support to automatically format the code for the power-server project</description>

</project>
6 changes: 4 additions & 2 deletions metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<parent>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>power-server-metadata</artifactId>
<name>power-server : metadata model</name>
<description>Metadata model used by the power-server project, extracted to allow reuse in client projects</description>

<build>
<pluginManagement>
Expand All @@ -22,7 +24,7 @@
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>build-tools</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
package net.laprun.sustainability.power;

/**
* A power consumption measure as recorded by a sensor, recorded over a given period of time, with an ordering information
* provided by a tick. The meaning of each component measure is provided by the {@link SensorMetadata} information associated
* with the sensor.
*
* @param components an array recording the power consumption reported by each component of this sensor
* @param tick the ordinal tick associated with this measure
*/
public record SensorMeasure(double[] components, long tick) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,33 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The metadata associated with a power-consumption recording sensor. This allows to make sense of the data sent by the power
* server by providing information about each component (e.g. CPU) recorded by the sensor during each periodical measure.
*/
public class SensorMetadata {
/**
* The information associated with a recorded component
*
* @param name the name of the component (e.g. CPU)
* @param index the index at which the measure for this component is recorded in the {@link SensorMeasure#components} array
* @param description a short textual description of what this component is about when available (for automatically
* extracted components, this might be identical to the name)
* @param isAttributed whether or not this component provides an attributed value i.e. whether the value is already computed
* for the process during a measure or, to the contrary, if the measure is done globally and the computation of the
* attributed share for each process needs to be performed. This is needed because some sensors only provide
* system-wide measures instead of on a per-process basis.
* @param unit a textual representation of the unit used for measures associated with this component (e.g. mW)
*/
public record ComponentMetadata(String name, int index, String description, boolean isAttributed, String unit) {
}

/**
* Initializes sensor metadata information
*
* @param components a map describing the metadata for each component
* @param documentation a text providing any relevant information associated with the described sensor
*/
@JsonCreator
public SensorMetadata(@JsonProperty("metadata") Map<String, ComponentMetadata> components,
@JsonProperty("documentation") String documentation) {
Expand All @@ -23,26 +46,55 @@ public SensorMetadata(@JsonProperty("metadata") Map<String, ComponentMetadata> c
@JsonProperty("documentation")
private final String documentation;

/**
* Determines whether a component with the specified name is known for this sensor
*
* @param component the name of the component
* @return {@code true} if a component with the specified name exists for the associated sensor, {@code false} otherwise
*/
public boolean exists(String component) {
return components.containsKey(component);
}

public ComponentMetadata metadataFor(String component) {
/**
* Retrieves the {@link ComponentMetadata} associated with the specified component name if it exists
*
* @param component the name of the component which metadata is to be retrieved
* @return the {@link ComponentMetadata} associated with the specified name
* @throws IllegalArgumentException if no component with the specified name is known for the associated sensor
*/
public ComponentMetadata metadataFor(String component) throws IllegalArgumentException {
final var componentMetadata = components.get(component);
if (componentMetadata == null) {
throw new IllegalArgumentException("Unknown component: " + component);
}
return componentMetadata;
}

/**
* Retrieves the number of known components for the associated sensor
*
* @return the cardinality of known components
*/
public int componentCardinality() {
return components.size();
}

/**
* Retrieves the known {@link ComponentMetadata} for the associated sensor as an unmodifiable Map keyed by the components'
* name
*
* @return an unmodifiable Map of the known {@link ComponentMetadata}
*/
public Map<String, ComponentMetadata> components() {
return Collections.unmodifiableMap(components);
}

/**
* Retrieves the documentation, if any, associated with this SensorMetadata
*
* @return the documentation relevant for the associated sensor
*/
public String documentation() {
return documentation;
}
Expand Down
Loading
Loading