Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
098d6f1
playing with node js
vadzim-vys Jan 10, 2022
f23ccb1
moved more code
vadzim-vys Jan 11, 2022
472793b
test record
vadzim-vys Jan 11, 2022
5cc8268
validate changelog using new script
vadzim-vys Jan 11, 2022
65554cf
moved mbx-ci to the bin folder
vadzim-vys Jan 11, 2022
499cfee
print dependencies md
vadzim-vys Jan 12, 2022
145d777
removed redundant code
vadzim-vys Jan 12, 2022
a322b14
added release changelog script
vadzim-vys Jan 12, 2022
a66ae97
release notes like we do this
vadzim-vys Jan 12, 2022
c986e03
fixed notes
vadzim-vys Jan 12, 2022
f6e8065
wip
vadzim-vys Jan 13, 2022
162d8fd
generate changelog using new script
vadzim-vys Jan 17, 2022
aa90ee8
moved validate changelog script out
vadzim-vys Jan 17, 2022
2e575ca
create pr for changelog
vadzim-vys Jan 17, 2022
7b1edd5
use new validate changelog script
vadzim-vys Jan 17, 2022
e2c1717
fixed validate changelog script
vadzim-vys Jan 17, 2022
092f433
fixed create changelog entry script
vadzim-vys Jan 17, 2022
7501725
clenup changelog
vadzim-vys Jan 17, 2022
0e0ac09
test adding release notes to changelog
vadzim-vys Jan 18, 2022
fb64f52
update current changelog file
vadzim-vys Jan 18, 2022
f4d1efb
updated script
vadzim-vys Jan 18, 2022
b2a72ca
added inputs/outputs for generate dependencies task
vadzim-vys Jan 18, 2022
238c3e1
fixed path
vadzim-vys Jan 18, 2022
d05508a
fixed release creation command
vadzim-vys Jan 18, 2022
f792bd8
got rid of bash
vadzim-vys Jan 18, 2022
038ec1c
added failing test
vadzim-vys Jan 19, 2022
808cb4c
fixed failing test
vadzim-vys Jan 19, 2022
5dc143c
fixed formatting
vadzim-vys Jan 19, 2022
c682e3c
cleanup root build.gradle
vadzim-vys Jan 19, 2022
2018350
got rid of hardcoded values
vadzim-vys Jan 19, 2022
6e8c7b4
test 2.0.x warning
vadzim-vys Jan 19, 2022
7ad845b
limit entry types support
vadzim-vys Jan 19, 2022
195f6ad
let add a few changelog entries per pr
vadzim-vys Jan 20, 2022
7adc9e7
rename refactoring
vadzim-vys Jan 20, 2022
6af894f
update changelog at main as well
vadzim-vys Jan 20, 2022
30c208d
fixed dry run
vadzim-vys Jan 20, 2022
4c5df00
fixed changelog validation
vadzim-vys Jan 20, 2022
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
19 changes: 7 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,11 @@ commands:
verify-changelog:
steps:
- run:
name: Install python dependencies
command: python3 -m pip install requests
name: Install js dependencies
command: npm install
- run:
name: Verify that a changelog entry is present in CHANGELOG.md
command: |
MBX_CI_GITHUB_TOKEN=$(./mbx-ci github reader token)
if [[ -n "$CIRCLE_PULL_REQUEST" ]]; then
python3 scripts/validate-changelog.py ${CIRCLE_PULL_REQUEST##*/} ${MBX_CI_GITHUB_TOKEN}
else
echo "Not a PR, skipping changelog validation."
fi
command: ./scripts/validate-changelog.js

assemble-module:
parameters:
Expand Down Expand Up @@ -408,7 +402,7 @@ commands:
- deploy:
name: Publish stable artifacts in SDK Registry
command: |
export GITHUB_TOKEN=$(./mbx-ci github writer private token)
export GITHUB_TOKEN=$(mbx-ci github writer private token)
git config --global user.email no-reply@mapbox.com && git config --global user.name mapbox-ci
make publish-to-sdk-registry

Expand Down Expand Up @@ -438,13 +432,14 @@ commands:
name: Install mbx-ci
command: |
curl -Ls https://mapbox-release-engineering.s3.amazonaws.com/mbx-ci/latest/mbx-ci-linux-amd64 > mbx-ci && chmod 755 ./mbx-ci
mv ./mbx-ci /usr/local/bin/mbx-ci

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed some way to access mbx-ci from scripts/github.js


setup-aws-credentials:
steps:
- run:
name: Obtain AWS credentials
command: |
./mbx-ci aws setup
mbx-ci aws setup

#--------------------------
#---------- JOBS ----------
Expand Down Expand Up @@ -538,7 +533,7 @@ jobs:
- run:
name: Publish API docs Android
command: |
GITHUB_WRITER_TOKEN=$(./mbx-ci github writer public token)
GITHUB_WRITER_TOKEN=$(mbx-ci github writer public token)
git remote set-url origin "https://x-access-token:$GITHUB_WRITER_TOKEN@github.com/mapbox/mapbox-navigation-android"
git config --global user.email no-reply@mapbox.com && git config --global user.name mapbox-ci
./scripts/publish_api_docs_android.sh -p $GITHUB_WRITER_TOKEN -t $CIRCLE_TAG
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ build/

jacoco.exec
qa-test-app/src/main/res/values/mapbox_access_token.xml

#node
node_modules/**
package-lock.json
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ dokkaHtmlMultiModule {
task clean(type: Delete) {
delete rootProject.buildDir
}

apply from: "${rootDir}/gradle/changelog.gradle"
7 changes: 7 additions & 0 deletions changelogs/unreleased/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"ticket": 5338,
"type": "fixed",
"title": "Fixed something"
}
]
7 changes: 7 additions & 0 deletions changelogs/unreleased/vv-running-changelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"ticket": 1234,
"type": "added",
"title": "test 2"
}
]
15 changes: 15 additions & 0 deletions gradle/changelog.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apply from: "${rootDir}/gradle/dependencies.gradle"

task createDependenciesMd {
inputs.properties(this.ext.version)
outputs.file("$buildDir/dependencies.md")
doLast {
def versions = "- Mapbox Maps SDK v${this.ext.version.mapboxMapSdk} ([release notes](https://github.com/mapbox/mapbox-maps-android/releases/tag/android-v${this.ext.version.mapboxMapSdk})) \n" +
"- Mapbox Navigation Native v${this.ext.version.mapboxNavigator} \n" +
"- Mapbox Core Common v${this.ext.version.mapboxCommonNative} \n" +
"- Mapbox Java v${this.ext.version.mapboxSdkServices} ([release notes](https://github.com/mapbox/mapbox-java/releases/tag/v${this.ext.version.mapboxSdkServices})) \n" +
"- Mapbox Android Core v${this.ext.version.mapboxCore} \n" +
"- Mapbox Android Telemetry v${this.ext.version.mapboxEvents} "
new File(buildDir, "dependencies.md").text = versions
}
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "mapbox-navigation-android",
"version": "0.0.0",
"scripts": {
"test": "mocha scripts/**/*.test.js --inline-diffs"
},
"devDependencies": {
"@octokit/rest": "^17.1.1",
"parse-git-patch": "^1.0.7",
"prompts": "^2.4.1",
"minimist": "^1.2.5",
"semver": "^7.3.5",
"mocha": "9.1.4",
"mock-fs": "5.1.2"
}
}
35 changes: 35 additions & 0 deletions scripts/create-changelog-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

const { createEntry } = require("./libs/changelog")
const minimist = require("minimist")


async function main() {
try {
const argv = minimist(process.argv.slice(2), {
string: [
'ticket',
'type',
'message'
],
boolean: [
'dry-run'
],
alias: {
'dry-run': 'isDryRun'
},
default: {
isDryRun: false
},
unknown: function (name) {
throw `parameter ${name} isn't supported`
}
});
createEntry(argv)
} catch(error) {
console.error(error)
console.log("Usage")
}
}

main()
114 changes: 114 additions & 0 deletions scripts/create-changelog-pr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env node

const semver = require('semver')
const { compileChangeLog, compileReleaseNotesMd, removeEntries, addReleaseNotesToChangelogMD } = require("./libs/changelog")
const path = require('path');
const { execSync } = require('child_process');
const fs = require('fs');

let BUILD_DIR = path.join(".", "build")
const CHANGELOG_PATH = path.join(".", "CHANGELOG.md")

try {
main()
} catch (err) {
console.error(err)
console.error('Usage: scripts/changelog-pr --version [release version, for example 1.0.0] [--branch main] [--dry-run]');
}

function main() {
let args = parseArguments()
// TODO: check if GH exists
// TODO: check if branch matches current one
console.log("Generating dependencies.md")
execSync("./gradlew createDependenciesMd")
let dependenciesMd = fs.readFileSync(path.join(".", "build", "dependencies.md"))
console.log("Generated dependencies.md")

console.log("Compiling changelog")
let changelog = compileReleaseNotesMd({
version: args.version,
dependenciesMd: dependenciesMd
})

let executor = args.isDryRun
? execSyncDryRun
: execSync

let releaseNotesTempFile = path.join(BUILD_DIR, "RELEASENOTES.md")
if (args.isDryRun) {
console.log("Dry run. Generated changelog:")
console.log(changelog)
} else {
fs.writeFileSync(releaseNotesTempFile, changelog)
removeEntries()
updateChangelogMDFile(changelog)
}


executor(`git checkout -b add-changelog-${args.version}`)
executor(`git add .`)
executor(`git commit -m "created changelog for ${args.version}"`)
executor(`gh config set prompt disabled`)
executor(`git push --set-upstream origin add-changelog-${args.version}`)
executor(`gh pr create --base ${args.branch} --title "Changelog for ${args.version}" --body "" --reviewer mapbox/navigation-android`)
executor(`gh release create ${args.version} --draft --target ${args.branch} --notes-file ${releaseNotesTempFile} --title ${args.version}`)
if (args.branch != "main") {
executor(`git checkout main`)
executor(`git checkout -b add-changelog-${args.version}-update-main`)
if (args.isDryRun) {
console.log("updating changelog at main branch")
} else {
updateChangelogMDFile(changelog)
}
executor(`git add .`)
executor(`git commit -m "Changelog for ${args.version}"`)
executor(`git push origin add-changelog-${args.version}-update-main`)
executor(`gh pr create --base main --title "Changelog for ${args.version}" --body "" --reviewer mapbox/navigation-android`)
}
executor(`git checkout ${args.branch}`)
Comment on lines +44 to +69

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If somebody launches the script from a not main branch, for example release-2.1, script opens 2 PRs with updates in the CHANGELOG.md file, one for the release-2.1 and one for the main branch.
@mapbox/navigation-android , @LukasPaczos , do you like this approach?

Alternatively we can update CHANGELOG.md automatically in the main branch only and update a release branch manually or not to update a release branch at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Not I'm not sure that this is an approach we use. All our changes go through the master branch and then they're cherry-picked to release branch. 馃
Guys I need help with this 馃槃

Comment on lines +49 to +69

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to replace ifs by polymorphism and make the flow testable

}

function updateChangelogMDFile(newReleaseChangelog) {
let existingChangelog = fs.readFileSync(CHANGELOG_PATH).toString()
let updatedChangelog = addReleaseNotesToChangelogMD(existingChangelog, newReleaseChangelog)
fs.writeFileSync(CHANGELOG_PATH, updatedChangelog)
}

function execSyncDryRun(command) {
console.log(`dry-run: ${command}`)
}

function parseArguments() {
const argv = require("minimist")(process.argv.slice(2), {
string: [
'branch',
'version'
],
boolean: [
'dry-run'
],
default: {
branch: "main",
'dry-run': false
},
unknown: function (name) {
throw `parameter ${name} isn't supported`
}
});

let result = {}

result.isDryRun = argv['dry-run']
result.branch = argv.branch

result.version = argv.version
if (result.version == undefined) {
throw "you must specify a version for release"
}
if (!semver.valid(result.version)) {
throw `passed version ${result.version} isn't SemVer compatible`
}

return result
}
Loading