Skip to content

Commit

Permalink
Merge pull request #80 from clarin-eric/master
Browse files Browse the repository at this point in the history
Update 'dev' branch with latest changes from master
  • Loading branch information
andmor- authored Apr 25, 2024
2 parents 7b9ecd4 + 7011105 commit eaa07c2
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 46 deletions.
104 changes: 83 additions & 21 deletions .github/workflows/release_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,103 @@ name: Build and release wheel
on:
push:
branches:
- "master"
- "master"
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+rc[x0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc[x0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc[x0-9]+'
pull_request:
release:
types: [published]
workflow_dispatch:
defaults:
run:
shell: bash

jobs:
prepare:
name: "Prepare"
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
create_release: ${{ steps.check_release.outputs.CREATE_RELEASE }}
steps:
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Check create release for tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
id: check_release
run: |
URL="https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.get_version.outputs.VERSION }}"
StatusCode=$(curl -o -I -L -s -w "%{http_code}" -X GET -G $URL)
if [ "$StatusCode" == 200 ]; then
echo "Release exists"
echo "CREATE_RELEASE=false" >> $GITHUB_OUTPUT
else
echo "Release does not exist"
echo "CREATE_RELEASE=true" >> $GITHUB_OUTPUT
fi
build_wheel:
needs: [prepare]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build wheel
run: |
cd ..
docker run -v ./Centre-Registry:/src -v ./whl:/whl registry.gitlab.com/clarin-eric/docker-alpine-wheeler:0.0.1-a6
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: true
body_path: CHANGELOG.md
- name: Add to release
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker run -v ./Centre-Registry:/src -v ./whl:/whl registry.gitlab.com/clarin-eric/docker-alpine-wheeler:0.0.1-a10
- name: 'Tar wheeler output and changelog'
run: tar -cvf workspace.tar ../whl/*.whl ./CHANGELOG.md
- uses: actions/upload-artifact@v4
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /home/runner/work/Centre-Registry/whl/*.whl
asset_content_type: application/gzip
name: workspace
path: workspace.tar
retention-days: 1
release:
name: "Release"
needs: [prepare, build_wheel]
# Run job for github releases and tag pushes (without github release)
if: github.event_name == 'release' || needs.prepare.outputs.create_release == 'true'
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: 'Download workspace'
uses: actions/download-artifact@v4
with:
name: workspace
- name: 'Untar workspace'
run: tar -xvf workspace.tar
# For github releases -> upload release package to existing release
# For tag pushes without github release -> create a github release with release package
- name: Create release
if: needs.prepare.outputs.create_release == 'true'
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ needs.prepare.outputs.version }}
name: ${{ needs.prepare.outputs.version }}
draft: false
prerelease: true
bodyFile: CHANGELOG.md
- name: Add to existing release
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Pseudo-ternary expression: get "upload_url" from the release created above, or from github "release" event when release is pre-created
upload_url: ${{ needs.prepare.outputs.create_release == 'true' && steps.create_release.outputs.upload_url || github.event.release.upload_url }}
asset_path: ./whl/*.whl
asset_content_type: application/gzip
- uses: eregon/publish-release@v1
if: needs.prepare.outputs.create_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ env:
addons:
sauce_connect: true
install:
- pip install -e 'centre-registry-app/'
- pip install -e .
- pip install -r 'centre-registry-app/requirements_test.txt'
script:
- Centre-Registry-config/manage.py migrate
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Changelog

## [3.0.1] - 28.03.2024
## [3.0.1] - 25.04.2024

### New features
- `api/all_centres_full` endpoint for CLARIN website
- project root `.pytoml` building Centre Registry packages (`centre-registry-app`; `Centre-Registry-config`) into a single package
- `.whl` build and distribution via release
- `api/all_centres_full` endpoint for main website consumption

### Changed features
- Fixed validation of geographical coordinates on administration interface. #79
- Updated dependencies:
- Django 4.1.11 to Django 4.2.11
- django-debug-toolbar 4.2.0 to 4.3.0
- Jsonschema 4.19.1 to 4.21.1
- lxml 4.9.3 to 4.9.4
- lxml 4.9.3 to 5.2.1
- Selenium 4.13.0 to 4.19.0
- Added dependency on djangorestframework 3.15.1

Expand Down
3 changes: 1 addition & 2 deletions Centre-Registry-config/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ maintainers = [
"Andre Moreira <[email protected]>",
"<[email protected]>"
]

packages = [
{ include = "centre_registry_project" },
]

[tool.poetry.urls]
changelog = "https://github.com/clarin-eric/Centre-Registry/blob/master/LICENSE.txt"
documentation = "https://trac.clarin.eu/wiki/Centre%20Registry"
documentation = "https://github.com/clarin-eric/Centre-Registry/"
homepage = "https://centres.clarin.eu/"
repository = "https://github.com/clarin-eric/Centre-Registry/"

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Gives a KML file (Keyhole Markup) with geographical information about Centres of
use in mapping applications. For example: `api/KML/EBC`

`api/model/M`, where M is one of the models in the administration interface `CentreType`,
`Centre`, `Contact`, `Consortium`, `FCSEndpoint`, `URLReference`, `MetadataFormat`,
`OAIPMHEndpoint`, `SAMLIdentityFederation`, `SAMLServiceProvider`:
`Centre`, `Contact`, `Consortium`, `FCSEndpoint`, `URLReference`, `Organisation`,
`OAIPMHEndpoint`, `OAIPMHEndpointSet`, `SAMLIdentityFederation`, `SAMLServiceProvider`:
Gives a JSON representation of all data belonging to that model in the database.

`api/all_centres_full`, for all Centres of any type with fully expanded relations into values
Expand Down
21 changes: 15 additions & 6 deletions centre-registry-app/centre_registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
from django.db.models import CASCADE, PROTECT, SET_NULL, SET_DEFAULT, SET, DO_NOTHING


def raise_coordinate_validation_error(coordinate, exception):
raise ValidationError(
'{0} is not a valid Decimal Degree coordinate. '.format(
str(coordinate))) from exception


def parse_decimal_degree(degree):
"""
Extracts a float decimal degree from a string.
"""
return re_match(r'^[+\-]{0,1}[0-9]{1,3}\.[0-9]{1,8}$', degree).group(0)
return re_match(r'^[+\-]{0,1}[0-9]{1,3}\.[0-9]{1,18}$', degree).group(0)


def is_valid_longitude(longitude):
Expand All @@ -33,19 +39,22 @@ def is_valid_latitude(latitude):

def validate_latitude(latitude):
try:
if is_valid_longitude(parse_decimal_degree(latitude)):
if is_valid_latitude(parse_decimal_degree(latitude)):
return
else:
raise_coordinate_validation_error(latitude)
except Exception as exception:
raise ValidationError(
'{0} is not a valid Decimal Degree latitude. '.format(
str(latitude))) from exception
raise_coordinate_validation_error(latitude, exception)


def validate_longitude(longitude):
try:
if is_valid_longitude(parse_decimal_degree(longitude)):
return
except Exception as exception:import ast
else:
raise_coordinate_validation_error(longitude)
except Exception as exception:
raise_coordinate_validation_error(longitude, exception)


class Contact(Model):
Expand Down
12 changes: 10 additions & 2 deletions centre-registry-app/centre_registry/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from rest_framework import serializers

from centre_registry.models import AssessmentDates
from centre_registry.models import Centre
from centre_registry.models import CentreType
from centre_registry.models import Contact
Expand All @@ -10,8 +11,7 @@
class CentreTypeSerializer(serializers.ModelSerializer):
class Meta:
model = CentreType
fields = '__all__'

fields = ['type']

class ContactSerializer(serializers.ModelSerializer):
class Meta:
Expand All @@ -30,6 +30,13 @@ class Meta:
model = Organisation
fields = '__all__'

class AssessmentDatesSerializer(serializers.ModelSerializer):
type = CentreTypeSerializer(many=True)

class Meta:
model = AssessmentDates
exclude = ['id']


class CentreSerializer(serializers.ModelSerializer):
type = CentreTypeSerializer(many=True)
Expand All @@ -38,6 +45,7 @@ class CentreSerializer(serializers.ModelSerializer):
monitoring_contacts = ContactSerializer(many=True)
consortium = ConsortiumSerializer()
organisation_fk = OrganisationSerializer()
assessmentdates = AssessmentDatesSerializer(many=True)

class Meta:
model = Centre
Expand Down
5 changes: 2 additions & 3 deletions centre-registry-app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ packages = [
{ include = "centre_registry" },
]


[tool.poetry.urls]
changelog = "https://github.com/clarin-eric/Centre-Registry/blob/master/LICENSE.txt"
documentation = "https://trac.clarin.eu/wiki/Centre%20Registry"
documentation = "https://github.com/clarin-eric/Centre-Registry/"
homepage = "https://centres.clarin.eu/"
repository = "https://github.com/clarin-eric/Centre-Registry/"

Expand All @@ -32,7 +31,7 @@ django-debug-toolbar = '4.3.0'
djangorestframework = '3.15.1'

[tool.poetry.group.test.dependencies]
lxml = '4.9.4'
lxml = '5.2.1'
selenium = '4.19.0'
jsonschema = '4.21.1'
django-test-migrations = '1.3.0'
Expand Down
23 changes: 17 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "clarin_centre_registry"
description = "CLARIN Centre Registry Django project configuration"
version = "3.0.1-rc"
version = "0.0.0dev"
license = "../LICENSE.txt"
authors = [
"Beatriz Sanchez Bribian",
Expand All @@ -14,15 +14,14 @@ maintainers = [
"Andre Moreira <[email protected]>",
"<[email protected]>"
]

packages = [
{ include = "centre_registry_project", from = "Centre-Registry-config" },
{ include = "centre_registry", from = "centre-registry-app" },
]

[tool.poetry.urls]
changelog = "https://github.com/clarin-eric/Centre-Registry/blob/master/LICENSE.txt"
documentation = "https://trac.clarin.eu/wiki/Centre%20Registry"
documentation = "https://github.com/clarin-eric/Centre-Registry/"
homepage = "https://centres.clarin.eu/"
repository = "https://github.com/clarin-eric/Centre-Registry/"

Expand All @@ -33,11 +32,23 @@ django-debug-toolbar = '4.3.0'
djangorestframework = '3.15.1'

[tool.poetry.group.test.dependencies]
lxml = '4.9.4'
lxml = '5.2.1'
selenium = '4.19.0'
jsonschema = '4.21.1'
django-test-migrations = '1.3.0'

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
pattern = "^(?P<base>\\d+\\.\\d+\\.\\d+)(-?((?P<stage>[a-zA-Z]+)\\.?(?P<revision>\\d+)?))?"
format-jinja = """
{%- if distance == 0 -%}
{{ serialize_pep440(base, stage, revision) }}
{%- else -%}
{{ serialize_pep440(base, stage, revision, dev=distance, metadata=[commit]) }}
{%- endif -%}
"""

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

0 comments on commit eaa07c2

Please sign in to comment.