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

Release 1.0.0 #328

Merged
merged 7 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 31 additions & 0 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,34 @@ jobs:
TITLE: ${{ github.event.pull_request.title }}
NUMBER: ${{ github.event.pull_request.number }}
URL: ${{ github.event.pull_request.html_url }}

serialization-version:
# if you have a dependent job that is skipped (i.e. you want to bump the version but not have a changelog entry) you must add
# always() before your actual condition you want for the job
# https://github.com/actions/runner/issues/491#issuecomment-660122693
if: always() && github.event.pull_request.merged && github.repository_owner == 'entur' && contains(github.event.pull_request.labels.*.name, 'bump serialization id')
runs-on: ubuntu-latest
needs: [changelog-entry]
permissions:
contents: write
steps:
- name: Install xmllint
run: |
sudo apt-get install -y libxml2-utils
- name: Checkout
uses: actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump serialization version
run: |
version=`xmllint --xpath "//*[local-name()='lamassu.serialization.version.id']/text()" pom.xml`
bumped=$((version+1))
sed -Ei "s/<lamassu\.serialization\.version\.id>.*<\/lamassu\.serialization\.version\.id>/<lamassu\.serialization\.version\.id>${bumped}<\/lamassu\.serialization\.version\.id>/" pom.xml
git add pom.xml
git commit -m "Bump serialization version id for #${NUMBER}"
# just for safety as the Github repo is eventually consistent, therefore this push competes with the changelog entry one
git pull --rebase origin master
git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:master
env:
# Use environment variables to prevent injection attack
NUMBER: ${{ github.event.pull_request.number }}
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<description>Micro mobility aggregation</description>

<properties>
<lamassu.serialization.version.id>18</lamassu.serialization.version.id>

<java.version>21</java.version>

<graphql-starter.version>15.1.0</graphql-starter.version>
Expand Down Expand Up @@ -208,6 +210,15 @@
</dependencies>

<build>
<!--
Filtering will perform substitution on lamassu-project-info.properties,
-->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand All @@ -233,6 +244,14 @@
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<propertiesEncoding>UTF-8</propertiesEncoding>
</configuration>
</plugin>
<plugin>
<groupId>com.hubspot.maven.plugins</groupId>
<artifactId>prettier-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.entur.gbfs.validation.model.ValidationResult;
import org.entur.lamassu.cache.StationSpatialIndexId;
import org.entur.lamassu.cache.VehicleSpatialIndexId;
import org.entur.lamassu.config.project.LamassuProjectInfoConfiguration;
import org.entur.lamassu.model.entities.GeofencingZones;
import org.entur.lamassu.model.entities.Station;
import org.entur.lamassu.model.entities.Vehicle;
Expand All @@ -16,6 +17,7 @@
import org.redisson.codec.Kryo5Codec;
import org.redisson.config.Config;
import org.redisson.spring.data.connection.RedissonConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -33,18 +35,19 @@ public class RedissonCacheConfig {
public static final String VALIDATION_REPORTS_CACHE_KEY = "validationReportsCache";
public static final String CACHE_READY_KEY = "cacheReady";

@Value("${org.entur.lamassu.serializationVersion}")
private String serializationVersion;

private final String serializationVersion;
private final Config redissonConfig;

public RedissonCacheConfig(
@Value("${org.entur.lamassu.redis.master.host}") String masterHost,
@Value("${org.entur.lamassu.redis.master.port}") String masterPort,
@Value("${org.entur.lamassu.redis.slave.enabled:false}") boolean slaveEnabled,
@Value("${org.entur.lamassu.redis.slave.host:na}") String slaveHost,
@Value("${org.entur.lamassu.redis.slave.port:na}") String slavePort
@Value("${org.entur.lamassu.redis.slave.port:na}") String slavePort,
@Autowired LamassuProjectInfoConfiguration lamassuProjectInfoConfiguration
testower marked this conversation as resolved.
Show resolved Hide resolved
) {
serializationVersion = lamassuProjectInfoConfiguration.getSerializationVersion();

redissonConfig = new Config();

var codec = new Kryo5Codec(this.getClass().getClassLoader());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
*
*
* * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
* * the European Commission - subsequent versions of the EUPL (the "Licence");
* * You may not use this work except in compliance with the Licence.
* * You may obtain a copy of the Licence at:
* *
* * https://joinup.ec.europa.eu/software/page/eupl
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the Licence is distributed on an "AS IS" basis,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the Licence for the specific language governing permissions and
* * limitations under the Licence.
*
*/

/*
*
*
* * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
* * the European Commission - subsequent versions of the EUPL (the "Licence");
* * You may not use this work except in compliance with the Licence.
* * You may obtain a copy of the Licence at:
* *
* * https://joinup.ec.europa.eu/software/page/eupl
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the Licence is distributed on an "AS IS" basis,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the Licence for the specific language governing permissions and
* * limitations under the Licence.
*
*/

package org.entur.lamassu.config.project;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class LamassuProjectInfo {

private static final String FILENAME = "lamassu-project-info.properties";

static LamassuProjectInfo loadFromProperties() throws IOException {
InputStream in =
LamassuProjectInfo.class.getClassLoader().getResourceAsStream(FILENAME);
Properties props = new java.util.Properties();
props.load(in);

return new LamassuProjectInfo(
props.getProperty("project.version"),
props.getProperty("lamassu.serialization.version.id")
);
}

private final String projectVersion;
private final String serializationVersion;

LamassuProjectInfo(String projectVersion, String serializationVersion) {
this.projectVersion = projectVersion;
this.serializationVersion = serializationVersion;
}

public String getProjectVersion() {
return projectVersion;
}

public String getSerializationVersion() {
return serializationVersion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
*
*
* * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
* * the European Commission - subsequent versions of the EUPL (the "Licence");
* * You may not use this work except in compliance with the Licence.
* * You may obtain a copy of the Licence at:
* *
* * https://joinup.ec.europa.eu/software/page/eupl
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the Licence is distributed on an "AS IS" basis,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the Licence for the specific language governing permissions and
* * limitations under the Licence.
*
*/

package org.entur.lamassu.config.project;

import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LamassuProjectInfoConfiguration {

private static final Logger LOG = LoggerFactory.getLogger(
LamassuProjectInfoConfiguration.class
);

private final LamassuProjectInfo projectInfo;

public LamassuProjectInfoConfiguration() throws IOException {
this.projectInfo = LamassuProjectInfo.loadFromProperties();
LOG.info("Project version: {}", getProjectVersion());
LOG.info("Serialization version : {}", getSerializationVersion());
}

public String getSerializationVersion() {
return projectInfo.getSerializationVersion();
}

public String getProjectVersion() {
return projectInfo.getProjectVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.entur.lamassu.config.project.LamassuProjectInfoConfiguration;
import org.entur.lamassu.model.entities.Vehicle;
import org.entur.lamassu.service.GeoSearchService;
import org.redisson.api.RFuture;
Expand All @@ -27,18 +28,19 @@ public class AdminController {
private final GeoSearchService geoSearchService;
RMapCache<String, Vehicle> vehicleCache;

@Value("${org.entur.lamassu.serializationVersion}")
private String serializationVersion;
private final String serializationVersion;

@Autowired
testower marked this conversation as resolved.
Show resolved Hide resolved
public AdminController(
RedissonClient redissonClient,
GeoSearchService geoSearchService,
RMapCache<String, Vehicle> vehicleCache
RMapCache<String, Vehicle> vehicleCache,
LamassuProjectInfoConfiguration lamassuProjectInfoConfiguration
) {
this.redissonClient = redissonClient;
this.geoSearchService = geoSearchService;
this.vehicleCache = vehicleCache;
this.serializationVersion = lamassuProjectInfoConfiguration.getSerializationVersion();
}

@GetMapping("/cache_keys")
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ org.entur.lamassu.redis.master.port=6379

#logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG

org.entur.lamassu.serializationVersion=1
spring.profiles.active=leader

org.entur.lamassu.enableValidation=true
3 changes: 3 additions & 0 deletions src/main/resources/lamassu-project-info.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Maven performs variable substitution on this file
[email protected]@
lamassu.serialization.version.id=@lamassu.serialization.version.id@