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

Generate relase notes #1

Merged
merged 11 commits into from
Apr 6, 2021
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
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!-- Thanks for sending a pull request! Before submitting your PR, some kind reminder

* If this is your first PR, please read our contributor guidelines: https://github.com/vgramer/opa-idea-plugin/blob/master/CONTRIBUTING.md
* If this is your first PR, please read our contributor guidelines: https://github.com/open-policy-agent/opa-idea-plugin/blob/master/CONTRIBUTING.md

* Code should be accompanied by tests whenever it's possible.

* New feature must be documented

For more information about the project architecture please take a look at https://github.com/vgramer/opa-idea-plugin/tree/master/docs/devel
For more information about the project architecture please take a look at https://github.com/open-policy-agent/opa-idea-plugin/tree/master/docs/devel

-->

Expand Down
14 changes: 14 additions & 0 deletions .github/release-notes-pr-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Update changelog

# Description
This PR is generated by the GitHub action and automatically updated when
Pr(s) are merged on master.

It should stay in draft until we release.

# Merging instruction
This pr must be merged last, just before releasing.

1. edit the title of last release notes to change `NEXT_VERSION`by the actual version (you can do it in GitHub interface)
1. merge pr using **squashing** strategy
1. tag the `master` branch with the actual version (this will create a Github release and publish the plugin on Jetbrains store)
18 changes: 18 additions & 0 deletions .github/release-notes.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Release notes for NEXT_VERSION

{{with .NotesWithActionRequired -}}
## Urgent Upgrade Notes

### (No, really, you MUST read this before you upgrade)

{{range .}}{{println "-" .}} {{end}}
{{end}}

{{- if .Notes -}}
## Changes by Kind
{{ range .Notes}}
### {{.Kind | prettyKind}}

{{range $note := .NoteEntries }}{{println "-" $note}}{{end}}
{{- end -}}
{{- end -}}
75 changes: 75 additions & 0 deletions .github/workflows/release_and_pulbish_plugin_on_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: publish plugin on JB and create release on GH

on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
jobs:
check-gradle-wrapper:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1

publish_plugin:
runs-on: ubuntu-latest
needs: [check-gradle-wrapper]
strategy:
matrix:
platform-version: [ 201, 202 ]
env:
ORG_GRADLE_PROJECT_platformVersion: ${{ matrix.platform-version }}
ORG_GRADLE_PROJECT_publishChannel: dev #todo change that after test
ORG_GRADLE_PROJECT_publishToken: ${{ secrets.PUBLISH_TOKEN }}
steps:
# Cache gradle dependencies
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: publish plugin
run: |
ORG_GRADLE_PROJECT_pluginVersion="${GITHUB_REF/refs\/tags\//}"
./gradlew :plugin:publishPlugin

- name: Upload artifact
uses: actions/[email protected]
with:
name: plugin-artifact
path: ./build/distributions/*.zip
retention-days: 1
if-no-files-found: error

create_github_release:
runs-on: ubuntu-latest
needs : [ publish_plugin ]
steps:
- uses: actions/checkout@v2
- name: Download Artifact
uses: actions/download-artifact@v2
id: download
with:
name: plugin-artifact
path: ./artifacts/

- name: create or update release note PR
env:
# Required for the `hub` CLI
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${GITHUB_REF/refs\/tags\//}"
echo -e "${VERSION}\n" > gh_release_description.md
sed -e '0,/Release notes for v/d' -e '/Release notes for v/,$d' CHANGELOG.md >> gh_release_description.md

assets=''
for file in $(ls ./artifacts/); do assets="${assets} -a ./artifacts/${file}"; done
echo "assets=${assets}"

hub release create -F gh_release_description.md ${assets} "${VERSION}"
27 changes: 27 additions & 0 deletions .github/workflows/upset_release_notes_pr_on_push_on_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Create or update release notes PR

on:
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
upset_release_notes_pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# needed to be able to resolve commit of previous version
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: "1.16"
- name: Download release-note tool
run: GO111MODULE=on go get k8s.io/release/cmd/[email protected]

- name: create or update release note PR
env:
# Required for the `hub` CLI
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./hack/create_or_update_release_notes_pr.sh
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ build/
gen/
deps

# MacOS files
.DS_Store

# release-notes file
next-release-notes.md
tmp_changelog.md
gh_release_description
121 changes: 121 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Release notes for v0.5.0

## Changes by Kind

### Refactoring

- Grammar: rename rules:
- `expr` to `literal-expr`
- `expr2` to `expr` ([#93](https://github.com/open-policy-agent/opa-idea-plugin/pull/93), [@vgramer](https://github.com/vgramer))
- Remove references to old repo `vgramer/opa-idea-plugin`. The repository has been transferred to `open-policy-agent` organization ([#83](https://github.com/open-policy-agent/opa-idea-plugin/pull/83), [@vgramer](https://github.com/vgramer))

### Bug or Regression

- Grammar: allow factor expression (ie parenthesis ). These expressions were passed as an error:
- `a4:= (1 - 3) - (2 +5)`
- `reverse(l) = [l[j] | _ = l[i]; j := (count(l) - 1) - i]` ([#92](https://github.com/open-policy-agent/opa-idea-plugin/pull/92), [@vgramer](https://github.com/vgramer))
- Grammar: allow complex expression as array index. These expressions were parsed as an error:
- `x:= x[minus(count(x),1)]`
- `index_last(l, x) = t[minus(count(t), 1)] { #something} else = -1 { # something}`
- `rule1{ x:= x[count(x) - 1)] }` ([#91](https://github.com/open-policy-agent/opa-idea-plugin/pull/91), [@vgramer](https://github.com/vgramer))
- Grammar: allow complex expression for array and object value. these expressions were parsed as an error:
- `arr7 := [1 + 2 - 4, count(arr6) / abs(arr5[0])`
- `a6 := { a: 1 > 2, b: { c: object.get(a2, a, default) + abs(c) - 2 }}` ([#90](https://github.com/open-policy-agent/opa-idea-plugin/pull/90), [@vgramer](https://github.com/vgramer))
- Grammar: allow empty query in else clause. These expressions were reported as an error
- `foo = true { input.x < input.y } else = false`
- `foo = true { false } else = { true }` ([#85](https://github.com/open-policy-agent/opa-idea-plugin/pull/85), [@vgramer](https://github.com/vgramer))


# Release notes for v0.4.0

## Changes by Kind

### Feature

- Implement auto closing quote feature ([#69](https://github.com/open-policy-agent/opa-idea-plugin/pull/69), [@vgramer](https://github.com/vgramer))
- Run [intellij-plugin-verifier](https://github.com/JetBrains/intellij-plugin-verifier) to check plugin binary compatibility in github action

1. update `org.jetbrains.intellij` Gradle plugin because the new version offers a task to run the plugin verifier. Consequently, remove the `ideaDependencyCachePath`customization which is not needed anymore.
2. add a job to run plugin verifier ([#62](https://github.com/open-policy-agent/opa-idea-plugin/pull/62), [@vgramer](https://github.com/vgramer))

### Bug or Regression

- Fix tests for github action and macOS Big Sur ([#73](https://github.com/open-policy-agent/opa-idea-plugin/pull/73), [@vgramer](https://github.com/vgramer))
- Grammar: allow import between rules and complex expression in else statement ([#80](https://github.com/open-policy-agent/opa-idea-plugin/pull/80), [@vgramer](https://github.com/vgramer))
- Grammar: don't allow multi-line in strings ([#67](https://github.com/open-policy-agent/opa-idea-plugin/pull/67), [@vgramer](https://github.com/vgramer))
- Grammar: fix rule-head and expr-infix
- `a:= 1 + 2` was parsed as an error
- assignment was valid inside affectation (eg `a := b = 1 + 2`) but should not.
- `a := 1 + 2 +3` was parsed as an error ([#74](https://github.com/open-policy-agent/opa-idea-plugin/pull/74), [@vgramer](https://github.com/vgramer))


# Release notes for v0.3.0

## Changes by Kind

### Bug or Regression

- Grammar: allow to use of infix operation as argument of a function. This expression was parsed as an error:
- `ARule(){ x := count({x} & {y}) }` ([#64](https://github.com/open-policy-agent/opa-idea-plugin/pull/64), [@vgramer](https://github.com/vgramer))

# Release notes for v0.2.0

## Changes by Kind

### Feature

- Implements auto-closing feature (brace, parenthesis and bracket ) ([#41](https://github.com/open-policy-agent/opa-idea-plugin/pull/41), [@vgramer](https://github.com/vgramer))
- Improve speed and security of CI Job:
- Cache gradle dependencies between run.
- check the signature of the Gradle wrapper. More info at [https://github.com/gradle/wrapper-validation-action](https://github.com/gradle/wrapper-validation-action) ([#55](https://github.com/open-policy-agent/opa-idea-plugin/pull/55), [@vgramer](https://github.com/vgramer))

### Documentation

- Fix typo in the documentation ([#54](https://github.com/open-policy-agent/opa-idea-plugin/pull/54), [@lukasz-kaminski](https://github.com/lukasz-kaminski))
- Update instruction du use stable channel when installing opa though Jetbrains market place ([#53](https://github.com/open-policy-agent/opa-idea-plugin/pull/53), [@vgramer](https://github.com/vgramer))

### Bug or Regression

- Grammar: access to function's return value without assigning it to a variable. These expressions were parsed as an error:
- `fun_obj(x) = h { h := {"a": {"b": [x,2]}} }`
- `aRule { a = fun_obj(1).a }` ([#59](https://github.com/open-policy-agent/opa-idea-plugin/pull/59), [@vgramer](https://github.com/vgramer))

# Release notes for v0.1.0

## Changes by Kind

### Refactoring

- Add tests on grammar and validate test files with `opa check` command ([#40](https://github.com/open-policy-agent/opa-idea-plugin/pull/40), [@irodzik](https://github.com/irodzik))
- Refactoring of Opa action codes and improve comment ([#38](https://github.com/open-policy-agent/opa-idea-plugin/pull/38), [@asadali](https://github.com/asadali))

### Feature

- Add the following opa action
- trace of selected text to code
- check ([#37](https://github.com/open-policy-agent/opa-idea-plugin/pull/37), [@frankiecerk](https://github.com/frankiecerk))
- Add the script to check that versioned source files (`*.java`; `*.kt`) contains the license header and call it in github action ([#49](https://github.com/open-policy-agent/opa-idea-plugin/pull/49), [@vgramer](https://github.com/vgramer))
- Build flavored ide. Some features like creating a rego project is only available on IDEA. This PR allows building the different flavors of the plugin for each ide version. This is transparent for the user (he see only one plugin market place) ([#44](https://github.com/open-policy-agent/opa-idea-plugin/pull/44), [@vgramer](https://github.com/vgramer))
- Grammar: add `%` operator and tests for grammar ([#39](https://github.com/open-policy-agent/opa-idea-plugin/pull/39), [@irodzik](https://github.com/irodzik))
- Implements auto-closing feature (brace, parenthesis and bracket ) ([#41](https://github.com/open-policy-agent/opa-idea-plugin/pull/41), [@vgramer](https://github.com/vgramer))
- Index TOTO in rego comment ([#26](https://github.com/open-policy-agent/opa-idea-plugin/pull/26), [@vgramer](https://github.com/vgramer))
- OpaTestRunConfiguration: add the full output of the command to the root node ([#52](https://github.com/open-policy-agent/opa-idea-plugin/pull/52), [@vgramer](https://github.com/vgramer))
- Support for opa test, test coverage on project workspace and opa check on current open document, shows output in console window (all support for console window showing output is in extensions/OPAActionToolWindow) ([#30](https://github.com/open-policy-agent/opa-idea-plugin/pull/30), [@frankiecerk](https://github.com/frankiecerk))

### Documentation

- Add opa icon for plugin installation ([#36](https://github.com/open-policy-agent/opa-idea-plugin/pull/36), [@vgramer](https://github.com/vgramer))
- Add user and tech documentation ([#3](https://github.com/open-policy-agent/opa-idea-plugin/pull/3), [@vgramer](https://github.com/vgramer))
- Instructions for download plugin from Jetbrains market place ([#48](https://github.com/open-policy-agent/opa-idea-plugin/pull/48), [@frankiecerk](https://github.com/frankiecerk))

### Bug or Regression

- Fix test run configuration:
- Don't discriminate test configurations based on the file name:
- user can eval or test a package in any rego file
- user can test any rule starting with `test_`in any rego file
- user can evaluate any rule not starting with `test_` in any rego file
- Make bundle dir parameter required to create a test configuration => avoid message `Testing Framework quit unexpectedly` when creating a test configuration from gutter
- Generated name of the runConfiguration start with the name of the command to easily know which configuration type will be generated ([#50](https://github.com/open-policy-agent/opa-idea-plugin/pull/50), [@vgramer](https://github.com/vgramer))
- Grammar: fixed string regex
highlighting for rule heads ([#19](https://github.com/open-policy-agent/opa-idea-plugin/pull/19), [@frankiecerk](https://github.com/frankiecerk))%
56 changes: 51 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.gradle.api.JavaVersion.VERSION_1_8
import org.gradle.api.internal.HasConvention
import org.intellij.markdown.ast.getTextInNode
import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.grammarkit.tasks.GenerateParser
import org.jetbrains.intellij.tasks.RunIdeTask
Expand All @@ -26,6 +27,16 @@ val baseVersion = when (baseIDE) {
val psiViewerPluginVersion = prop("psiViewerPluginVersion")
val channel = prop("publishChannel")

buildscript {
repositories {
mavenCentral()
}
dependencies {
// needed to extract the last release notes
classpath("org.jetbrains:markdown:0.2.0")
}
}

idea {
module {
// https://github.com/gradle/kotlin-dsl/issues/537/
Expand Down Expand Up @@ -102,6 +113,7 @@ allprojects {
withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
sinceBuild(prop("sinceBuild"))
untilBuild(prop("untilBuild"))
changeNotes(getLastReleaseNotes())
}

withType<RunIdeTask> {
Expand All @@ -126,13 +138,12 @@ allprojects {

val channelSuffix = if (channel.isBlank() || channel == "stable") "" else "-$channel"
val versionSuffix = "-$platformVersion$channelSuffix"
val majorVersion = prop("majorVersion")
val patchVersion = prop("patchVersion").toInt()
val buildNumber = System.getenv("GITHUB_RUN_ID" ) ?: "SNAPSHOT"
val pluginVersion = prop("pluginVersion")


// module to build/run/publish opa-ida-plugin plugin
project(":plugin"){
version = "$majorVersion.$patchVersion.$buildNumber$versionSuffix"
version = "$pluginVersion$versionSuffix"
intellij {
pluginName = "opa-idea-plugin"
val plugins = mutableListOf(
Expand Down Expand Up @@ -229,4 +240,39 @@ val SourceSet.kotlin: SourceDirectorySet


fun SourceSet.kotlin(action: SourceDirectorySet.() -> Unit) =
kotlin.action()
kotlin.action()

fun getLastReleaseNotes(changLogPath: String = "CHANGELOG.md"): String {
val src = File(changLogPath).readText()
val flavour = org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor()
val parsedTree = org.intellij.markdown.parser.MarkdownParser(flavour).buildMarkdownTreeFromString(src)

var found = false
val releaseNotesChildren: MutableList<org.intellij.markdown.ast.ASTNode> = mutableListOf()

for (child in parsedTree.children) {
if (child.type == org.intellij.markdown.MarkdownElementTypes.ATX_1) {
if (found) {
// collect finished. exit
break
}
if (child.getTextInNode(src).startsWith("# Release notes for v")) {
releaseNotesChildren.add(child)
found = true
}
} else {
if (found) { // collect child related to this release note
releaseNotesChildren.add(child)
}
}
}

if (!found) {
throw Exception("Can not find releases notes in '${changLogPath}'")
}
val root = org.intellij.markdown.ast.CompositeASTNode(
org.intellij.markdown.MarkdownElementTypes.MARKDOWN_FILE,
releaseNotesChildren
)
return org.intellij.markdown.html.HtmlGenerator(src, root, flavour).generateHtml()
}
2 changes: 1 addition & 1 deletion docs/devel/setup_development_env.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Just clone the project and execute the tests to ensure everything is ok.

```bash
# clone the project
$ git clone [email protected]:vgramer/opa-idea-plugin.git
$ git clone [email protected]:open-policy-agent/opa-idea-plugin.git
$ cd opa-idea-plugin

# run tests
Expand Down
3 changes: 1 addition & 2 deletions gradle-202.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ sinceBuild=202.6397
untilBuild=203.*

# # check the binary compatibility of the plugin against these idea versions ( more info at https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl)
# IC-203.5251.39 is the last eap, unfortunately i couldn't find an "alias" on the last EAP
pluginVerifierIdeVersions= IC-2020.2, IC-203.5251.39
pluginVerifierIdeVersions= IC-2020.2, IC-2020.3
Loading