Skip to content

Commit 72abda5

Browse files
committed
Impl: github workflow actions
- validate gradle wrapper - build & verify plugin - triggers UTs and UI tests - triggered on push on main branch and pull requests on all branches
1 parent d299c1b commit 72abda5

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

.github/workflows/build.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
2+
# - validate Gradle Wrapper,
3+
# - run 'test' and 'verifyPlugin' tasks,
4+
# - run 'buildPlugin' task and prepare artifact for the further tests,
5+
# - run 'runPluginVerifier' task,
6+
#
7+
# Workflow is triggered on push and pull_request events.
8+
#
9+
# GitHub Actions reference: https://help.github.com/en/actions
10+
#
11+
12+
13+
name: Coder Gateway Plugin Build
14+
on:
15+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
16+
push:
17+
branches: [ main ]
18+
# Trigger the workflow on any pull request
19+
pull_request:
20+
21+
jobs:
22+
23+
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
24+
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
25+
# Build plugin and provide the artifact for the next workflow jobs
26+
build:
27+
name: Build
28+
runs-on: ubuntu-latest
29+
outputs:
30+
version: ${{ steps.properties.outputs.version }}
31+
changelog: ${{ steps.properties.outputs.changelog }}
32+
steps:
33+
34+
# Check out current repository
35+
- name: Fetch Sources
36+
uses: actions/checkout@v2.4.0
37+
38+
# Validate wrapper
39+
- name: Gradle Wrapper Validation
40+
uses: gradle/wrapper-validation-action@v1.0.4
41+
42+
# Setup Java 11 environment for the next steps
43+
- name: Setup Java
44+
uses: actions/setup-java@v2
45+
with:
46+
distribution: zulu
47+
java-version: 11
48+
cache: gradle
49+
50+
# Set environment variables
51+
- name: Export Properties
52+
id: properties
53+
shell: bash
54+
run: |
55+
PROPERTIES="$(./gradlew properties --console=plain -q)"
56+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
57+
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
58+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
59+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
60+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
61+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
62+
echo "::set-output name=version::$VERSION"
63+
echo "::set-output name=name::$NAME"
64+
echo "::set-output name=changelog::$CHANGELOG"
65+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
66+
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
67+
# Run tests
68+
- name: Run Tests
69+
run: ./gradlew test
70+
71+
# Collect Tests Result of failed tests
72+
- name: Collect Tests Result
73+
if: ${{ failure() }}
74+
uses: actions/upload-artifact@v2
75+
with:
76+
name: tests-result
77+
path: ${{ github.workspace }}/build/reports/tests
78+
79+
# Cache Plugin Verifier IDEs
80+
- name: Setup Plugin Verifier IDEs Cache
81+
uses: actions/cache@v2.1.7
82+
with:
83+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
84+
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
85+
86+
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
87+
- name: Run Plugin Verification tasks
88+
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
89+
90+
# Collect Plugin Verifier Result
91+
- name: Collect Plugin Verifier Result
92+
if: ${{ always() }}
93+
uses: actions/upload-artifact@v2
94+
with:
95+
name: pluginVerifier-result
96+
path: ${{ github.workspace }}/build/reports/pluginVerifier
97+
98+
# Prepare plugin archive content for creating artifact
99+
- name: Prepare Plugin Artifact
100+
id: artifact
101+
shell: bash
102+
run: |
103+
cd ${{ github.workspace }}/build/distributions
104+
FILENAME=`ls *.zip`
105+
unzip "$FILENAME" -d content
106+
echo "::set-output name=filename::${FILENAME:0:-4}"
107+
# Store already-built plugin as an artifact for downloading
108+
- name: Upload artifact
109+
uses: actions/upload-artifact@v2.2.4
110+
with:
111+
name: ${{ steps.artifact.outputs.filename }}
112+
path: ./build/distributions/content/*/*

0 commit comments

Comments
 (0)