Skip to content

Commit

Permalink
Merge pull request #1131 from research-software-directory/codemeta-se…
Browse files Browse the repository at this point in the history
…rver

Codemeta server
  • Loading branch information
ewan-escience authored Feb 29, 2024
2 parents 7bdab6a + 1ad742b commit 8aa5a2d
Show file tree
Hide file tree
Showing 12 changed files with 470 additions and 14 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/codemeta_scan_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2024 Netherlands eScience Center
#
# SPDX-License-Identifier: Apache-2.0

name: codemeta code quality scan and build

on:
workflow_dispatch:
push:
branches:
- main
paths:
- "codemeta/**"
pull_request:
paths:
- "codemeta/**"

jobs:
codemeta-scan-build:
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.22.0' ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: "Build application with Go"
uses: actions/setup-go@v5
with:
go-version: '1.22.0'
- run: |
go build -v
working-directory: codemeta
- name: SonarCloud Scan codemeta
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: codemeta
4 changes: 2 additions & 2 deletions .github/workflows/e2e_tests_chrome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ jobs:
working-directory: .
run: |
cp e2e/.env.e2e .env
docker compose build --parallel database backend auth frontend documentation nginx
docker compose build --parallel database backend auth frontend documentation nginx codemeta swagger
- name: start rsd
working-directory: .
run: |
docker compose up --detach database backend auth frontend documentation nginx swagger
docker compose up --detach database backend auth frontend documentation nginx codemeta swagger
sleep 5
- name: run e2e tests in chrome
working-directory: e2e
Expand Down
31 changes: 23 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
echo skipped=${{needs.release_tag.outputs.skipped}}
echo tag=${{needs.release_tag.outputs.tag}}
auth:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: auth
Expand All @@ -70,7 +70,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}

database:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: database
Expand All @@ -85,7 +85,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}

backend:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: backend api
Expand All @@ -100,7 +100,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}

frontend:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: frontend
Expand All @@ -115,7 +115,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}

nginx:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: nginx
Expand All @@ -129,8 +129,23 @@ jobs:
secrets:
token: ${{secrets.GITHUB_TOKEN}}

codemeta:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: codemeta
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/rsd-saas/codemeta
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: codemeta/Dockerfile
docker_context: ./codemeta
secrets:
token: ${{secrets.GITHUB_TOKEN}}

scrapers:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: scrapers
Expand Down Expand Up @@ -160,7 +175,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}}

deployment_files:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: [ release_tag,auth,database,backend,frontend,nginx,scrapers,documentation ]
name: create deployment.zip
Expand Down Expand Up @@ -241,7 +256,7 @@ jobs:
files: deployment.zip

citation:
# it needs to be check on string value
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: [ release_tag, deployment_files, release_draft ]
name: citations
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all)
# SPDX-FileCopyrightText: 2022 - 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2022 - 2023 Netherlands eScience Center
# SPDX-FileCopyrightText: 2022 - 2023 dv4all
# SPDX-FileCopyrightText: 2022 - 2024 Christian Meeßen (GFZ) <[email protected]>
# SPDX-FileCopyrightText: 2022 - 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2022 - 2024 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
# SPDX-FileCopyrightText: 2022 - 2024 Netherlands eScience Center
# SPDX-FileCopyrightText: 2022 Jesús García Gonzalez (Netherlands eScience Center) <[email protected]>
# SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
#
Expand Down Expand Up @@ -34,7 +34,7 @@ start: clean
# open http://localhost to see the application running

install: clean
docker compose build database backend auth scrapers nginx # exclude frontend and wait for the build to finish
docker compose build database backend auth codemeta scrapers nginx # exclude frontend and wait for the build to finish
docker compose up --scale scrapers=0 --detach
cd frontend && yarn install
cd documentation && yarn install
Expand Down
17 changes: 17 additions & 0 deletions codemeta/Dockerfile
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

FROM golang:1.22.0-bullseye

WORKDIR /usr/src/app
COPY go.mod .
COPY **.go .

RUN go build -v -o /usr/local/bin/app

RUN useradd user
USER user

CMD ["app"]
34 changes: 34 additions & 0 deletions codemeta/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
SPDX-FileCopyrightText: 2024 Netherlands eScience Center
SPDX-License-Identifier: CC-BY-4.0
-->

# CodeMeta server

This module implements a [CodeMeta](https://codemeta.github.io/) server, using [V3](https://w3id.org/codemeta/v3.0) of the schema.

If your instance of the RSD is hosted on https://example.com/, you can access the CodeMeta server on https://example.com/codemeta/v3/. To get the CodeMeta data for a software page, just append its slug to this URL. For example, to get the CodeMeta data for software page on https://example.com/software/some-software, visit https://example.com/codemeta/v3/some-software/.

## Developing

This module is written in Go, version 1.22. You can find the installation instruction [here](https://go.dev/doc/install). If this page lists a newer version than the one we use, you can find all versions [here](https://go.dev/dl/). We currently don't have any external dependencies.

When developing and running it locally, you need a locally running RSD instance, and you should set the `POSTGREST_URL` environment variable to a value at which the PostgREST backend can be reached. This will probably be `http://localhost/api/v1`. You can also point it to a dev or production server instead.

To build the module, open a terminal in the `codemeta` directory and run

```shell
go build
```

This should produce an executable called `codemeta`. Run it with

```shell
POSTGREST_URL=http://localhost/api/v1 ./codemeta
```

You can then access the service on http://localhost:8000/v3/

You can also use an IDE to build and run it more easily.
8 changes: 8 additions & 0 deletions codemeta/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]>
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center
//
// SPDX-License-Identifier: Apache-2.0

module codemeta

go 1.22
Loading

0 comments on commit 8aa5a2d

Please sign in to comment.