Skip to content

Commit 0be00e1

Browse files
authored
Merge pull request #1 from AleksandrSl/dev
First version EAP
2 parents 0539482 + d889798 commit 0be00e1

File tree

78 files changed

+5231
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5231
-425
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,53 @@
11
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
22
# - validate Gradle Wrapper,
3-
# - run test and verifyPlugin tasks,
4-
# - run buildPlugin task and prepare artifact for the further tests,
5-
# - run IntelliJ Plugin Verifier,
3+
# - run 'test' and 'verifyPlugin' tasks,
4+
# - run Qodana inspections,
5+
# - run 'buildPlugin' task and prepare artifact for the further tests,
6+
# - run 'runPluginVerifier' task,
67
# - create a draft release.
78
#
89
# Workflow is triggered on push and pull_request events.
910
#
10-
# Docs:
11-
# - GitHub Actions: https://help.github.com/en/actions
12-
# - IntelliJ Plugin Verifier GitHub Action: https://github.com/ChrisCarini/intellij-platform-plugin-verifier-action
11+
# GitHub Actions reference: https://help.github.com/en/actions
1312
#
1413
## JBIJPPTPL
1514

1615
name: Build
17-
on: [push, pull_request]
16+
on:
17+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
18+
push:
19+
branches: [main]
20+
# Trigger the workflow on any pull request
21+
pull_request:
22+
1823
jobs:
1924

2025
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
21-
gradleValidation:
22-
name: Gradle Wrapper
23-
runs-on: ubuntu-latest
24-
steps:
25-
26-
# Check out current repository
27-
- name: Fetch Sources
28-
uses: actions/checkout@v2
29-
30-
# Validate wrapper
31-
- name: Gradle Wrapper Validation
32-
uses: gradle/wrapper-validation-action@v1.0.3
33-
34-
# Run verifyPlugin and test Gradle tasks
35-
test:
36-
name: Test
37-
needs: gradleValidation
38-
runs-on: ubuntu-latest
39-
steps:
40-
41-
# Setup Java 1.8 environment for the next steps
42-
- name: Setup Java
43-
uses: actions/setup-java@v1
44-
with:
45-
java-version: 1.8
46-
47-
# Check out current repository
48-
- name: Fetch Sources
49-
uses: actions/checkout@v2
50-
51-
# Cache Gradle dependencies
52-
- name: Setup Gradle Dependencies Cache
53-
uses: actions/cache@v2
54-
with:
55-
path: ~/.gradle/caches
56-
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
57-
58-
# Cache Gradle Wrapper
59-
- name: Setup Gradle Wrapper Cache
60-
uses: actions/cache@v2
61-
with:
62-
path: ~/.gradle/wrapper
63-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
64-
65-
# Run detekt, ktlint and tests
66-
- name: Run Linters and Test
67-
run: ./gradlew check
68-
69-
# Run verifyPlugin Gradle task
70-
- name: Verify Plugin
71-
run: ./gradlew verifyPlugin
72-
73-
# Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
74-
# Requires test job to be passed
26+
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
27+
# Build plugin and provide the artifact for the next workflow jobs
7528
build:
7629
name: Build
77-
needs: test
7830
runs-on: ubuntu-latest
7931
outputs:
80-
name: ${{ steps.properties.outputs.name }}
8132
version: ${{ steps.properties.outputs.version }}
8233
changelog: ${{ steps.properties.outputs.changelog }}
83-
artifact: ${{ steps.properties.outputs.artifact }}
8434
steps:
8535

86-
# Setup Java 1.8 environment for the next steps
87-
- name: Setup Java
88-
uses: actions/setup-java@v1
89-
with:
90-
java-version: 1.8
91-
9236
# Check out current repository
9337
- name: Fetch Sources
94-
uses: actions/checkout@v2
38+
uses: actions/checkout@v2.4.0
9539

96-
# Cache Gradle Dependencies
97-
- name: Setup Gradle Dependencies Cache
98-
uses: actions/cache@v2
99-
with:
100-
path: ~/.gradle/caches
101-
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
40+
# Validate wrapper
41+
- name: Gradle Wrapper Validation
42+
uses: gradle/wrapper-validation-action@v1.0.4
10243

103-
# Cache Gradle Wrapper
104-
- name: Setup Gradle Wrapper Cache
105-
uses: actions/cache@v2
44+
# Setup Java 11 environment for the next steps
45+
- name: Setup Java
46+
uses: actions/setup-java@v2
10647
with:
107-
path: ~/.gradle/wrapper
108-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
48+
distribution: zulu
49+
java-version: 11
50+
cache: gradle
10951

11052
# Set environment variables
11153
- name: Export Properties
@@ -114,133 +56,97 @@ jobs:
11456
run: |
11557
PROPERTIES="$(./gradlew properties --console=plain -q)"
11658
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
117-
NAME="$(echo "$PROPERTIES" | grep "^pluginName_:" | cut -f2- -d ' ')"
59+
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
11860
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
11961
CHANGELOG="${CHANGELOG//'%'/'%25'}"
12062
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
12163
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
122-
ARTIFACT="${NAME}-${VERSION}.zip"
123-
12464
echo "::set-output name=version::$VERSION"
12565
echo "::set-output name=name::$NAME"
12666
echo "::set-output name=changelog::$CHANGELOG"
127-
echo "::set-output name=artifact::$ARTIFACT"
128-
129-
# Build artifact using buildPlugin Gradle task
130-
- name: Build Plugin
131-
run: ./gradlew buildPlugin
132-
133-
# Upload plugin artifact to make it available in the next jobs
134-
- name: Upload artifact
135-
uses: actions/upload-artifact@v1
67+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
68+
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
69+
# Run tests
70+
- name: Run Tests
71+
run: ./gradlew test
72+
73+
# Collect Tests Result of failed tests
74+
- name: Collect Tests Result
75+
if: ${{ failure() }}
76+
uses: actions/upload-artifact@v2
13677
with:
137-
name: plugin-artifact
138-
path: ./build/distributions/${{ needs.build.outputs.artifact }}
139-
140-
# Verify built plugin using IntelliJ Plugin Verifier tool
141-
# Requires build job to be passed
142-
verify:
143-
name: Verify
144-
needs: build
145-
runs-on: ubuntu-latest
146-
steps:
78+
name: tests-result
79+
path: ${{ github.workspace }}/build/reports/tests
14780

148-
# Setup Java 1.8 environment for the next steps
149-
- name: Setup Java
150-
uses: actions/setup-java@v1
81+
# Cache Plugin Verifier IDEs
82+
- name: Setup Plugin Verifier IDEs Cache
83+
uses: actions/cache@v2.1.7
15184
with:
152-
java-version: 1.8
85+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
86+
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
15387

154-
# Check out current repository
155-
- name: Fetch Sources
156-
uses: actions/checkout@v2
88+
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
89+
- name: Run Plugin Verification tasks
90+
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
15791

158-
# Cache Gradle Dependencies
159-
- name: Setup Gradle Dependencies Cache
160-
uses: actions/cache@v2
92+
# Collect Plugin Verifier Result
93+
- name: Collect Plugin Verifier Result
94+
if: ${{ always() }}
95+
uses: actions/upload-artifact@v2
16196
with:
162-
path: ~/.gradle/caches
163-
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
97+
name: pluginVerifier-result
98+
path: ${{ github.workspace }}/build/reports/pluginVerifier
16499

165-
# Cache Gradle Wrapper
166-
- name: Setup Gradle Wrapper Cache
167-
uses: actions/cache@v2
168-
with:
169-
path: ~/.gradle/wrapper
170-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
100+
# Run Qodana inspections
101+
- name: Qodana - Code Inspection
102+
uses: JetBrains/qodana-action@v4.2.5
171103

172-
# Set environment variables
173-
- name: Export Properties
174-
id: properties
104+
# Prepare plugin archive content for creating artifact
105+
- name: Prepare Plugin Artifact
106+
id: artifact
175107
shell: bash
176108
run: |
177-
PROPERTIES="$(./gradlew properties --console=plain -q)"
178-
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
179-
180-
echo "::set-output name=ideVersions::$IDE_VERSIONS"
181-
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
182-
183-
# Cache Plugin Verifier IDEs
184-
- name: Setup Plugin Verifier IDEs Cache
185-
uses: actions/cache@v2
109+
cd ${{ github.workspace }}/build/distributions
110+
FILENAME=`ls *.zip`
111+
unzip "$FILENAME" -d content
112+
echo "::set-output name=filename::${FILENAME:0:-4}"
113+
# Store already-built plugin as an artifact for downloading
114+
- name: Upload artifact
115+
uses: actions/upload-artifact@v2.2.4
186116
with:
187-
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
188-
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
189-
190-
# Run IntelliJ Plugin Verifier action using GitHub Action
191-
- name: Verify Plugin
192-
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
117+
name: ${{ steps.artifact.outputs.filename }}
118+
path: ./build/distributions/content/*/*
193119

194120
# Prepare a draft release for GitHub Releases page for the manual verification
195121
# If accepted and published, release workflow would be triggered
196122
releaseDraft:
197123
name: Release Draft
198124
if: github.event_name != 'pull_request'
199-
needs: [build, verify]
125+
needs: build
200126
runs-on: ubuntu-latest
201127
steps:
202128

203129
# Check out current repository
204130
- name: Fetch Sources
205-
uses: actions/checkout@v2
131+
uses: actions/checkout@v2.4.0
206132

207133
# Remove old release drafts by using the curl request for the available releases with draft flag
208134
- name: Remove Old Release Drafts
209135
env:
210136
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211137
run: |
212-
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
213-
| tr '\r\n' ' ' \
214-
| jq '.[] | select(.draft == true) | .id' \
215-
| xargs -I '{}' \
216-
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
217-
138+
gh api repos/{owner}/{repo}/releases \
139+
--jq '.[] | select(.draft == true) | .id' \
140+
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
218141
# Create new release draft - which is not publicly visible and requires manual acceptance
219142
- name: Create Release Draft
220-
id: createDraft
221-
uses: actions/create-release@v1
222-
env:
223-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224-
with:
225-
tag_name: v${{ needs.build.outputs.version }}
226-
release_name: v${{ needs.build.outputs.version }}
227-
body: ${{ needs.build.outputs.changelog }}
228-
draft: true
229-
230-
# Download plugin artifact provided by the previous job
231-
- name: Download Artifact
232-
uses: actions/download-artifact@v2
233-
with:
234-
name: plugin-artifact
235-
236-
# Upload artifact as a release asset
237-
- name: Upload Release Asset
238-
id: upload-release-asset
239-
uses: actions/upload-release-asset@v1
240143
env:
241144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
242-
with:
243-
upload_url: ${{ steps.createDraft.outputs.upload_url }}
244-
asset_path: ./${{ needs.build.outputs.artifact }}
245-
asset_name: ${{ needs.build.outputs.artifact }}
246-
asset_content_type: application/zip
145+
run: |
146+
gh release create v${{ needs.build.outputs.version }} \
147+
--draft \
148+
--title "v${{ needs.build.outputs.version }}" \
149+
--notes "$(cat << 'EOM'
150+
${{ needs.build.outputs.changelog }}
151+
EOM
152+
)"

0 commit comments

Comments
 (0)