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

Version log #5348

Merged
merged 2 commits into from
Oct 2, 2019
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ env:
1lASf2BeeJC8rRz75MgRKnlf7Py6BA9GbNprzMdgxNPlUtrEkp9ExLvC7MZs7H0RvwxBgQmepQG5Mdg="
- secure: "Vt9O18grAUS3cf4tzbqY1YuQyCJTsPNh5lA79/q8viAcrJg0fAeNQEBoUyCAzztlgL53PrzLWTYIuK6Fw1t+td8hmEST\
l7fPSlVbGB6C/iG0d+cnIq31rjnliIdErXIAcB4JwE3yIRx+5aVEMBpAUhRuzBhGCt6iZwjhhFEr/D8="
# GITHUB_TOKEN
- secure: "NPvBo8Qbi/Idxv3XGnh6J5ui+z8YTpRvpGzResJyXcIrMvIWgBBDvldACUCaPuabOGlwciy+nSWWYn2JLVZ2peoMgr9n\
KEhRfGCvZBD5K/E+C73+41Cwsk0K+zJx5YRPYy9bYa4iuIwXfABGyiTWGYjLq8o3xxcx4Dwlmaqj1j8="
- MAIN_BRANCH=2.4
- MAJOR_VERSION=2.4

Expand Down
203 changes: 203 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,14 @@ spell:
-name .mypy_cache -prune -or \
-name '__pycache__' -prune -or \
-name _build -prune -or \
\( -type f -and -not -name '*.png' -and -not -name '*.mo' -and -not -name '*.po*' \
-and -not -name 'CONST_Makefile_tmpl' -and -not -name 'package-lock.json' \) -print)
\( -type f \
-and -not -name '*.png' \
-and -not -name '*.mo' \
-and -not -name '*.po*' \
-and -not -name 'CONST_Makefile_tmpl' \
-and -not -name 'package-lock.json' \
-and -not -name 'changelog.yaml' \
-and -not -name 'CHANGELOG.md' \) -print)


YAML_FILES ?= $(shell find \
Expand All @@ -331,6 +337,7 @@ YAML_FILES ?= $(shell find \
-name .mypy_cache -prune -or \
-name functional -prune -or \
-name geomapfish.yaml -prune -or \
-name changelog.yaml -prune -or \
\( -name "*.yml" -or -name "*.yaml" \) -print)
.PHONY: yamllint
yamllint:
Expand Down
6 changes: 3 additions & 3 deletions geoportal/c2cgeoportal_geoportal/scaffolds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def _epsg2bbox(srid):
return [r1["x"], r2["y"], r2["x"], r1["y"]]
except requests.RequestException:
print("Failed to establish a connexion to epsg.io.")
return None
except json.JSONDecodeError:
print("epsg.io doesn't return a correct json.")
return None
except IndexError:
print("Unable to get the bbox")
return None
except Exception as exception:
print('unexpected error: {}'.format(str(exception)))
return None


def fix_executables(output_dir, patterns, in_const_create_template=False):
Expand Down
159 changes: 159 additions & 0 deletions travis/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#!/usr/bin/env python3

import json
import os
import re
import subprocess
import sys

import requests
import yaml


REPOS = ('c2cgeoportal', 'ngeo')

with open('travis/changelog.yaml') as cl_file:
changelog = yaml.load(cl_file, Loader=yaml.CSafeLoader)


def save():
with open('travis/changelog.yaml', 'w') as cl_file_w:
cl_file_w.write(yaml.dump(changelog, Dumper=yaml.CSafeDumper))


def get_any(repo, ref, section, url):
if section not in changelog:
changelog[section] = {}
if repo not in changelog[section]:
changelog[section][repo] = {}

if ref in changelog[section][repo]:
return False, changelog[section][repo][ref]

json_stuff = requests.get(url.format(repo, ref), headers={
'Accept': 'application/vnd.github.groot-preview+json',
'Authorization': 'token {}'.format(os.environ['GITHUB_TOKEN'])
}).json()

changelog[section][repo][ref] = json_stuff
return True, json_stuff


def get_commit(repo, ref):
dirty, commit = get_any(repo, ref, 'commits', 'https://api.github.com/repos/camptocamp/{}/commits/{}')
if 'sha' not in commit:
print('Error on commit {}.'.format(ref))
print(commit)
sys.exit(1)
print(commit['sha'])

for key in list(commit.keys()):
if key not in ('parents', 'sha'):
del commit[key]
dirty = True
if commit['sha'] not in changelog['commits'][repo]:
changelog['commits'][repo][commit['sha']] = commit
dirty = True
if dirty:
save()
return commit


def get_pulls(repo, ref):
dirty, pulls = get_any(repo, ref, 'pulls', 'https://api.github.com/repos/camptocamp/{}/commits/{}/pulls')
if type(pulls) != list:
print('Error on commit {}.'.format(ref))
print(pulls)
sys.exit(1)
for pull in pulls:
if 'base' in pull:
pull['base_ref'] = pull['base']['ref']
print(pulls[0]['closed_at'])
print(pulls[0]['base_ref'])

for pull in pulls:
for key in list(pull.keys()):
if key not in (
'number', 'title', 'number', 'closed_at', 'created_at', 'html_url', 'state',
'updated_at', 'base_ref'
):
del pull[key]
dirty = True
if dirty:
save()
return pulls


def add_new_release():
if len(sys.argv) == 2:
npm_list = json.loads(subprocess.check_output([
'docker', 'run', '--rm', '--entrypoint=', 'camptocamp/geomapfish-build',
'npm', 'list', '--global', '--json'
]))

version = npm_list['dependencies']['ngeo']['version']
match = re.match(
r'([0-9]\.[0-9]\.[0-9])\-version\-[0-9]\.[0-9]\-latest\.[0-9]{8}T[0-9]{6}Z\.([0-9a-f]+)\.HEAD',
version
)

c2cgeoportal_ref = subprocess.check_call([
'git', 'log', 'pretty=format:%h', '--abbrev-commit', '-n1'
]).strip('\n ')

changelog['release'].append({
'ngeo': match.group(2),
'c2cgeoportal': c2cgeoportal_ref,
'name': sys.argv[1]
})


def add_commit(commits, all_pulls, repo, ref):
if ref not in commits:
pulls = get_pulls(repo, ref)
for pull in pulls:
all_pulls[pull['number']] = pull
commits[ref] = True
commit = get_commit(repo, ref)
# Get only the first parent to don't go in the pull request
add_commit(commits, all_pulls, repo, commit['parents'][0]['sha'])


def main():
add_new_release()

first = True
release_pulls = {}
commits = {}
for repo in REPOS:
commits[repo] = {}

for release in changelog['releases']:
if first:
for repo in REPOS:
commits[repo][get_commit(repo, release[repo])['sha']] = True
first = False
continue

release_pulls[release['name']] = {}
for repo in REPOS:
release_pulls[release['name']][repo] = {}
add_commit(
commits[repo],
release_pulls[release['name']][repo],
repo, release[repo]
)

with open('CHANGELOG.md', 'wt') as md_file:
for release, pulls in release_pulls.items():
md_file.write('##### {}\n'.format(release))
for repo in REPOS:
for pull in pulls[repo].values():
if pull['base_ref'] != 'master':
md_file.write('* {} [{}#{}]({})\n'.format(
pull['title'], repo, pull['number'], pull['html_url']
))


if __name__ == "__main__":
main()
Loading