Skip to content

Commit

Permalink
Merge pull request #1328 from research-software-directory/915-editorc…
Browse files Browse the repository at this point in the history
…onfig

Use EditorConfig
  • Loading branch information
ewan-escience authored Oct 28, 2024
2 parents a1cc2a8 + 6d5755d commit 712468c
Show file tree
Hide file tree
Showing 26 changed files with 337 additions and 219 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/editorconfig-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2024 Netherlands eScience Center
#
# SPDX-License-Identifier: Apache-2.0

name: EditorConfig Checker

on:
pull_request:

jobs:
editorconfig:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: editorconfig-checker/action-editorconfig-checker@main
- run: editorconfig-checker
17 changes: 17 additions & 0 deletions authentication/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2024 Netherlands eScience Center
#
# SPDX-License-Identifier: Apache-2.0

# EditorConfig is awesome: https://editorconfig.org

# Unix-style newlines with a newline ending every file and tab indentation
[**]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab

[**.md]
indent_style = unset
4 changes: 4 additions & 0 deletions authentication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ This module handles authentication from third parties using oAuth2 and OpenID.
## Environment variables
Check `.env.example` to see which environment variables are needed. In particular, look for the env variable `RSD_ENVIRONMENT` to allow for easy admin creation when developing and testing out the RSD (this is not safe for production!).

## Contributing

This module uses [EditorConfig](https://editorconfig.org/) for basic formatting. Please check if your editor [already supports EditorConfig](https://editorconfig.org/#pre-installed) or if you need to [install a plugin](https://editorconfig.org/#download). A GitHub workflow is run on every PR to check if any files violate the formatting settings.

## Developing locally
If you want to develop and run the auth module locally, i.e. outside of Docker, you have to make two changes to files tracked by Git.
1. In `docker-compose.yml`, add the following lines to the `nginx` service:
Expand Down
2 changes: 2 additions & 0 deletions authentication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ SPDX-FileCopyrightText: 2022 Matthias Rüster (GFZ) <matthias.ruester@gfz-potsda
SPDX-License-Identifier: Apache-2.0
-->

<!--editorconfig-checker-disable-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--editorconfig-checker-enable-->
<modelVersion>4.0.0</modelVersion>

<groupId>nl.research-software</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,50 @@ class UtilsTest {

@Test
void givenValidWellKnownData_whenExtractingTokenEndpoint_correctResultReturned() {
// editorconfig-checker-disable
String data = """
{
"token_endpoint_auth_signing_alg_values_supported": [
"RS256"
],
"id_token_signing_alg_values_supported": [
"RS256"
],
"userinfo_endpoint": "https://sandbox.orcid.org/oauth/userinfo",
"authorization_endpoint": "https://sandbox.orcid.org/oauth/authorize",
"token_endpoint": "https://sandbox.orcid.org/oauth/token",
"jwks_uri": "https://sandbox.orcid.org/oauth/jwks",
"claims_supported": [
"family_name",
"given_name",
"name",
"auth_time",
"iss",
"sub"
],
"scopes_supported": [
"openid"
],
"subject_types_supported": [
"public"
],
"response_types_supported": [
"code",
"id_token",
"id_token token"
],
"claims_parameter_supported": false,
"token_endpoint_auth_methods_supported": [
"client_secret_post"
],
"grant_types_supported": [
"authorization_code",
"implicit",
"refresh_token"
],
"issuer": "https://sandbox.orcid.org"
}""";
{
"token_endpoint_auth_signing_alg_values_supported": [
"RS256"
],
"id_token_signing_alg_values_supported": [
"RS256"
],
"userinfo_endpoint": "https://sandbox.orcid.org/oauth/userinfo",
"authorization_endpoint": "https://sandbox.orcid.org/oauth/authorize",
"token_endpoint": "https://sandbox.orcid.org/oauth/token",
"jwks_uri": "https://sandbox.orcid.org/oauth/jwks",
"claims_supported": [
"family_name",
"given_name",
"name",
"auth_time",
"iss",
"sub"
],
"scopes_supported": [
"openid"
],
"subject_types_supported": [
"public"
],
"response_types_supported": [
"code",
"id_token",
"id_token token"
],
"claims_parameter_supported": false,
"token_endpoint_auth_methods_supported": [
"client_secret_post"
],
"grant_types_supported": [
"authorization_code",
"implicit",
"refresh_token"
],
"issuer": "https://sandbox.orcid.org"
}""";
// editorconfig-checker-enable

URI tokenEndpoint = Utils.extractTokenUrlFromWellKnownData(data);

Expand Down
17 changes: 17 additions & 0 deletions backend-tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2024 Netherlands eScience Center
#
# SPDX-License-Identifier: Apache-2.0

# EditorConfig is awesome: https://editorconfig.org

# Unix-style newlines with a newline ending every file and tab indentation
[**]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab

[**.{md,yml}]
indent_style = unset
6 changes: 5 additions & 1 deletion backend-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: CC-BY-4.0

# Backend tests

This folder contains backend tests for the RSD. It is intended to mainly:
This folder contains backend tests for the RSD. It is intended to mainly:
- test the correctness of row level security rules
- test the correctness of remote procedure calls (no tests yet)
- load test the backend/database (no tests yet)
Expand All @@ -24,6 +24,10 @@ Tests should be written taking the following principles in account:
- each test should be runnable independently of other tests
- each test should be repeatable, without e.g. having to clean up the database first

## Contributing

This module uses [EditorConfig](https://editorconfig.org/) for basic formatting. Please check if your editor [already supports EditorConfig](https://editorconfig.org/#pre-installed) or if you need to [install a plugin](https://editorconfig.org/#download). A GitHub workflow is run on every PR to check if any files violate the formatting settings.

## Writing tests

Each class containing tests should be annotated with `@ExtendWith({SetupAllTests.class})`. This refers to a class containing a global setup method, which runs once to check the connection to the database and to initialise global parameters.
Expand Down
2 changes: 2 additions & 0 deletions backend-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ SPDX-FileCopyrightText: 2023 - 2024 Netherlands eScience Center
SPDX-License-Identifier: Apache-2.0
-->

<!--editorconfig-checker-disable-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--editorconfig-checker-enable-->
<modelVersion>4.0.0</modelVersion>

<groupId>nl.research-software</groupId>
Expand Down
17 changes: 17 additions & 0 deletions database/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2024 Netherlands eScience Center
#
# SPDX-License-Identifier: Apache-2.0

# EditorConfig is awesome: https://editorconfig.org

# Unix-style newlines with a newline ending every file and tab indentation
[**]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab

[**.md]
indent_style = unset
8 changes: 4 additions & 4 deletions database/104-person-views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- SPDX-FileCopyrightText: 2023 - 2024 Netherlands eScience Center
-- SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
-- SPDX-FileCopyrightText: 2023 dv4all
-- SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
--
-- SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -163,8 +164,8 @@ CREATE FUNCTION suggested_roles() RETURNS
VARCHAR[] LANGUAGE sql STABLE AS
$$
SELECT
ARRAY_AGG("role")
FROM (
ARRAY_AGG("role")
FROM (
SELECT
"role"
FROM
Expand All @@ -178,6 +179,5 @@ $$
team_member
WHERE
"role" IS NOT NULL
) roles
;
) roles;
$$;
20 changes: 20 additions & 0 deletions scrapers/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2024 Netherlands eScience Center
#
# SPDX-License-Identifier: Apache-2.0

# EditorConfig is awesome: https://editorconfig.org

# Unix-style newlines with a newline ending every file and tab indentation
[**]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = tab

[**.md]
indent_style = unset

[**.py]
indent_style = unset
4 changes: 4 additions & 0 deletions scrapers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ SPDX-License-Identifier: CC-BY-4.0

This module contains the scrapers used by the RSD. The scrapers are written in Java using Maven.

## Contributing

This module uses [EditorConfig](https://editorconfig.org/) for basic formatting. Please check if your editor [already supports EditorConfig](https://editorconfig.org/#pre-installed) or if you need to [install a plugin](https://editorconfig.org/#download). A GitHub workflow is run on every PR to check if any files violate the formatting settings.

## Running from within Docker Compose

If you have an instance of the RSD, including the scrapers, running with Docker Compose, you can manually run a scraper by running the respective command from the root of the project content:
Expand Down
7 changes: 4 additions & 3 deletions scrapers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ SPDX-FileCopyrightText: 2024 Jason Maassen (Netherlands eScience Center) <j.maas
SPDX-License-Identifier: Apache-2.0
-->

<!--editorconfig-checker-disable-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--editorconfig-checker-enable-->
<modelVersion>4.0.0</modelVersion>

<groupId>nl.research-software</groupId>
Expand Down Expand Up @@ -111,8 +113,8 @@ SPDX-License-Identifier: Apache-2.0
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
</dependency>

<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
Expand Down Expand Up @@ -179,6 +181,5 @@ SPDX-License-Identifier: Apache-2.0
</dependency>



</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2022 - 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]>
// SPDX-FileCopyrightText: 2022 - 2023 Netherlands eScience Center
// SPDX-FileCopyrightText: 2022 - 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
// SPDX-FileCopyrightText: 2022 - 2024 Netherlands eScience Center
// SPDX-FileCopyrightText: 2022 Christian Meeßen (GFZ) <[email protected]>
// SPDX-FileCopyrightText: 2022 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
//
Expand All @@ -10,9 +10,9 @@
import java.net.URI;

public class RsdResponseException extends Exception {

private static final long serialVersionUID = 1L;

public final int statusCode;
public final URI uri;
public final String body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ public class DataCiteReleaseRepository {

private static final Logger LOGGER = LoggerFactory.getLogger(DataCiteReleaseRepository.class);

// editorconfig-checker-disable
private static final String QUERY_UNFORMATTED = """
query {
works(ids: [%s], first: 10000) {
nodes {
doi
versionOfCount
relatedIdentifiers {
relationType
relatedIdentifierType
relatedIdentifier
}
}
}
}
""";
query {
works(ids: [%s], first: 10000) {
nodes {
doi
versionOfCount
relatedIdentifiers {
relationType
relatedIdentifierType
relatedIdentifier
}
}
}
}
""";
// editorconfig-checker-enable

public Map<Doi, Collection<ExternalMentionRecord>> getVersionedDois(Collection<Doi> conceptDois) {
if (conceptDois.isEmpty()) {
Expand Down
Loading

0 comments on commit 712468c

Please sign in to comment.