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

Changelog #5354

Merged
merged 2 commits into from
Oct 4, 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
53 changes: 40 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ env.CI = 'true'
env.DOCKER_USERNAME = 'amplerancid'

def clean() {
sh 'git clean -dx --force'
try {
sh 'git clean -dx --force'

sh 'docker ps --all | grep camptocamp/c2cgeoportal | awk \'{print($1)}\' | xargs --no-run-if-empty docker rm --force --volumes'
sh 'docker ps --all | grep camptocamp/geomapfish | awk \'{print($1)}\' | xargs --no-run-if-empty docker rm --force --volumes'
sh 'docker ps --all | grep camptocamp/testgeomapfish | awk \'{print($1)}\' | xargs --no-run-if-empty docker rm --force --volumes'
sh 'docker volume ls | grep home-jenkins-slave-workspace | awk \'{print($2)}\' | xargs --no-run-if-empty docker volume rm'
sh 'docker network rm internal || true'
sh 'docker ps --all | grep camptocamp/c2cgeoportal | awk \'{print($1)}\' | xargs --no-run-if-empty docker rm --force --volumes'
sh 'docker ps --all | grep camptocamp/geomapfish | awk \'{print($1)}\' | xargs --no-run-if-empty docker rm --force --volumes'
sh 'docker ps --all | grep camptocamp/testgeomapfish | awk \'{print($1)}\' | xargs --no-run-if-empty docker rm --force --volumes'
sh 'docker volume ls | grep home-jenkins-slave-workspace | awk \'{print($2)}\' | xargs --no-run-if-empty docker volume rm'
sh 'docker network rm internal || true'

sh 'docker ps'
sh 'docker ps --all --filter status=exited'
sh 'docker volume ls'
sh 'docker ps'
sh 'docker ps --all --filter status=exited'
sh 'docker volume ls'

sh 'travis/test-upgrade-convert.sh cleanup ${HOME}/workspace'
sh 'rm -rf ${HOME}/workspace/testgeomapfishapp'
sh 'rm -rf ${HOME}/workspace/geomapfish'
sh 'travis/test-upgrade-convert.sh cleanup ${HOME}/workspace'
sh 'rm -rf ${HOME}/workspace/testgeomapfishapp'
sh 'rm -rf ${HOME}/workspace/geomapfish'
} catch (Exception error) {
System.out.println("Unexpected error in clean");
error.printStackTrace(System.out);
}
}

def get_abort_ci() {
Expand Down Expand Up @@ -119,6 +124,19 @@ dockerBuild {
sh "docker tag camptocamp/geomapfish-build:${MAJOR_VERSION} camptocamp/geomapfish-build:${RELEASE_TAG}"
sh "docker tag camptocamp/geomapfish-config-build:${MAJOR_VERSION} camptocamp/geomapfish-config-build:${RELEASE_TAG}"
sh 'travis/test-upgrade-convert.sh init ${HOME}/workspace'

// Test changelog
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'geoportal_changelog_github_token',
usernameVariable: 'USERNAME',
passwordVariable: 'GITHUB_TOKEN'
]]) {
env.GITHUB_TOKEN = GITHUB_TOKEN
sh '.venv/bin/python travis/changelog new_version'
}
sh 'git diff CHANGELOG.md'
sh 'git checkout CHANGELOG.md travis/changelog.yaml'
}
stage('Tests') {
if (abort_ci()) { return }
Expand Down Expand Up @@ -329,7 +347,16 @@ dockerBuild {
sh '.venv/bin/python travis/clean-dockerhub-tags'

sshagent (credentials: ['c2c-infra-ci']) {
sh 'travis/publish'

withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'geoportal_changelog_github_token',
usernameVariable: 'USERNAME',
passwordVariable: 'GITHUB_TOKEN'
]]) {
env.GITHUB_TOKEN = GITHUB_TOKEN
sh 'travis/publish'
}
}
}
}, 'Push to Transifex': {
Expand Down
49 changes: 31 additions & 18 deletions travis/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import yaml
REPOS = ('c2cgeoportal', 'ngeo')

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


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


def output(cmd):
with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc:
return proc.stdout.read()


def get_any(repo, ref, section, url):
Expand Down Expand Up @@ -86,23 +91,28 @@ def get_pulls(repo, ref):

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'
]))
npm_list = json.loads(output([
'./docker-run', '--image=camptocamp/geomapfish-build', 'npm', 'list', '--global', '--json'
]).decode())
# For 2.5
# npm_list = json.loads(output([
# 'docker', 'run', '--rm', '--entrypoint=',
# 'camptocamp/geomapfish-build:{}'.format(os.environ['MAJOR_VERSION']),
# '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',
ngeo_ref = 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
)
).group(1)

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

changelog['release'].append({
'ngeo': match.group(2),
changelog['releases'].append({
'ngeo': ngeo_ref,
'c2cgeoportal': c2cgeoportal_ref,
'name': sys.argv[1]
})
Expand All @@ -126,6 +136,7 @@ def main():

first = True
release_pulls = {}
releases = []
commits = {}
for repo in REPOS:
commits[repo] = {}
Expand All @@ -137,6 +148,7 @@ def main():
first = False
continue

releases.append(release['name'])
release_pulls[release['name']] = {}
for repo in REPOS:
release_pulls[release['name']][repo] = {}
Expand All @@ -146,15 +158,16 @@ def main():
repo, release[repo]
)

with open('CHANGELOG.md', 'wt') as md_file:
for release, pulls in release_pulls.items()[::-1]:
md_file.write('##### {}\n'.format(release))
with open('CHANGELOG.md', 'wb') as md_file:
for release in releases[::-1]:
pulls = release_pulls[release]
md_file.write('##### {}\n'.format(release).encode('utf-8'))
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']
))
).encode('utf-8'))


if __name__ == "__main__":
Expand Down