Skip to content

Commit 2583637

Browse files
committed
Merge pull request 'ci:added licenses.yml' from ci/git-actions into master
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/onlyoffice-discourse/pulls/1
2 parents 788132f + 0379406 commit 2583637

File tree

7 files changed

+368
-0
lines changed

7 files changed

+368
-0
lines changed

.github/workflows/create-tag.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Create Tag
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths-ignore:
7+
- '.github/**'
8+
- '**/AUTHORS.md'
9+
- '**/LICENSE'
10+
- '**/README.md'
11+
12+
jobs:
13+
create-tag:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
- name: Get Info
19+
run: |
20+
echo "version=$(grep -Eo '[0-9]+(\.[0-9]+)+' CHANGELOG.md | head -n 1)" >> $GITHUB_OUTPUT
21+
id: info
22+
- name: Create Tag
23+
run: |
24+
git config user.name "$GITHUB_ACTOR"
25+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
26+
git tag -a 'v${{ steps.info.outputs.version }}' -m 'Release/v${{ steps.info.outputs.version }}'
27+
git push origin 'v${{ steps.info.outputs.version }}'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Discourse Plugin
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
ci:
11+
uses: discourse/.github/.github/workflows/discourse-plugin.yml@v1

.github/workflows/licenses.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Licenses
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [master, develop]
7+
pull_request:
8+
branches: [master, develop]
9+
10+
jobs:
11+
licences:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v6
18+
with:
19+
node-version: 16
20+
cache: yarn
21+
- name: Yarn install
22+
run: yarn install
23+
- name: Set up ruby
24+
uses: ruby/setup-ruby@v1
25+
with:
26+
ruby-version: 2.7
27+
bundler-cache: true
28+
- name: Bundle Install
29+
run: bundle install
30+
- name: Check Licenses
31+
uses: ONLYOFFICE/check-licenses@v1
32+
with:
33+
project_license: Apache-2.0

.github/workflows/lint.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [master, develop]
6+
pull_request:
7+
branches: [master, develop]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Ruby
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: '3.3'
21+
bundler-cache: true
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v4
30+
31+
- name: Get pnpm store directory
32+
shell: bash
33+
run: |
34+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
35+
36+
- name: Setup pnpm cache
37+
uses: actions/cache@v4
38+
with:
39+
path: ${{ env.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
43+
44+
- name: Install dependencies
45+
run: pnpm install
46+
47+
- name: Lint Ruby
48+
run: bundle exec rubocop
49+
50+
- name: Lint JavaScript
51+
run: pnpm lint:js
52+
53+
- name: Lint Handlebars
54+
run: pnpm lint:hbs
55+
56+
- name: Lint CSS
57+
run: pnpm lint:css
58+
59+
- name: Check formatting
60+
run: pnpm format:check
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Linting
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: plugin-linting-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: 16
24+
cache: yarn
25+
26+
- name: Yarn install
27+
run: yarn install
28+
29+
- name: Set up ruby
30+
uses: ruby/setup-ruby@v1
31+
with:
32+
ruby-version: 2.7
33+
bundler-cache: true
34+
35+
- name: ESLint
36+
if: ${{ always() }}
37+
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts
38+
39+
- name: Prettier
40+
if: ${{ always() }}
41+
shell: bash
42+
run: |
43+
yarn prettier -v
44+
if [ 0 -lt $(find assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
45+
yarn prettier --list-different "assets/**/*.{scss,js,es6}"
46+
fi
47+
if [ 0 -lt $(find test -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
48+
yarn prettier --list-different "test/**/*.{js,es6}"
49+
fi
50+
51+
- name: Ember template lint
52+
if: ${{ always() }}
53+
run: yarn ember-template-lint --no-error-on-unmatched-pattern assets/javascripts
54+
55+
- name: Rubocop
56+
if: ${{ always() }}
57+
run: bundle exec rubocop .

.github/workflows/plugin-tests.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Plugin Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: plugin-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
name: ${{ matrix.build_type }}
16+
runs-on: ubuntu-latest
17+
container: discourse/discourse_test:slim${{ startsWith(matrix.build_type, 'frontend') && '-browsers' || '' }}
18+
timeout-minutes: 30
19+
20+
env:
21+
DISCOURSE_HOSTNAME: www.example.com
22+
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
23+
RAILS_ENV: test
24+
PGUSER: discourse
25+
PGPASSWORD: discourse
26+
27+
strategy:
28+
fail-fast: false
29+
30+
matrix:
31+
build_type: ["backend", "frontend"]
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
with:
36+
repository: discourse/discourse
37+
fetch-depth: 1
38+
39+
- name: Install plugin
40+
uses: actions/checkout@v3
41+
with:
42+
path: plugins/${{ github.event.repository.name }}
43+
fetch-depth: 1
44+
45+
- name: Setup Git
46+
run: |
47+
git config --global user.email "ci@ci.invalid"
48+
git config --global user.name "Discourse CI"
49+
50+
- name: Start redis
51+
run: |
52+
redis-server /etc/redis/redis.conf &
53+
54+
- name: Start Postgres
55+
run: |
56+
chown -R postgres /var/run/postgresql
57+
sudo -E -u postgres script/start_test_db.rb
58+
sudo -u postgres psql -c "CREATE ROLE $PGUSER LOGIN SUPERUSER PASSWORD '$PGPASSWORD';"
59+
60+
- name: Bundler cache
61+
uses: actions/cache@v3
62+
with:
63+
path: vendor/bundle
64+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
65+
restore-keys: |
66+
${{ runner.os }}-gem-
67+
68+
- name: Setup gems
69+
run: |
70+
gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' Gemfile.lock)
71+
bundle config --local path vendor/bundle
72+
bundle config --local deployment true
73+
bundle config --local without development
74+
bundle install --jobs 4
75+
bundle clean
76+
77+
- name: Lint English locale
78+
if: matrix.build_type == 'backend'
79+
run: bundle exec ruby script/i18n_lint.rb "plugins/${{ github.event.repository.name }}/locales/{client,server}.en.yml"
80+
81+
- name: Get yarn cache directory
82+
id: yarn-cache-dir
83+
run: echo "::set-output name=dir::$(yarn cache dir)"
84+
85+
- name: Yarn cache
86+
uses: actions/cache@v3
87+
id: yarn-cache
88+
with:
89+
path: ${{ steps.yarn-cache-dir.outputs.dir }}
90+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
91+
restore-keys: |
92+
${{ runner.os }}-yarn-
93+
94+
- name: Yarn install
95+
run: yarn install
96+
97+
- name: Fetch app state cache
98+
uses: actions/cache@v3
99+
id: app-cache
100+
with:
101+
path: tmp/app-cache
102+
key: >-
103+
${{ hashFiles('.github/workflows/tests.yml') }}-
104+
${{ hashFiles('db/**/*', 'plugins/**/db/**/*') }}-
105+
106+
- name: Restore database from cache
107+
if: steps.app-cache.outputs.cache-hit == 'true'
108+
run: psql -f tmp/app-cache/cache.sql postgres
109+
110+
- name: Restore uploads from cache
111+
if: steps.app-cache.outputs.cache-hit == 'true'
112+
run: rm -rf public/uploads && cp -r tmp/app-cache/uploads public/uploads
113+
114+
- name: Create and migrate database
115+
if: steps.app-cache.outputs.cache-hit != 'true'
116+
run: |
117+
bin/rake db:create
118+
bin/rake db:migrate
119+
120+
- name: Dump database for cache
121+
if: steps.app-cache.outputs.cache-hit != 'true'
122+
run: mkdir -p tmp/app-cache && pg_dumpall > tmp/app-cache/cache.sql
123+
124+
- name: Dump uploads for cache
125+
if: steps.app-cache.outputs.cache-hit != 'true'
126+
run: rm -rf tmp/app-cache/uploads && cp -r public/uploads tmp/app-cache/uploads
127+
128+
- name: Check spec existence
129+
id: check_spec
130+
shell: bash
131+
run: |
132+
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then
133+
echo "::set-output name=files_exist::true"
134+
fi
135+
136+
- name: Plugin RSpec
137+
if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exist == 'true'
138+
run: bin/rake plugin:spec[${{ github.event.repository.name }}]
139+
140+
- name: Check QUnit existence
141+
id: check_qunit
142+
shell: bash
143+
run: |
144+
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
145+
echo "::set-output name=files_exist::true"
146+
fi
147+
148+
- name: Plugin QUnit
149+
if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exist == 'true'
150+
run: QUNIT_EMBER_CLI=1 bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000']
151+
timeout-minutes: 10

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
- name: Get Info
18+
run: |
19+
echo "version=$(grep -Eo '[0-9]+(\.[0-9]+)+' CHANGELOG.md | head -n 1)" >> $GITHUB_OUTPUT
20+
id: info
21+
- name: Generate Changelog
22+
run: |
23+
awk 'BEGIN {found=0} /^## [0-9]/ {if (!found) {found=1; next} else exit} found {print}' CHANGELOG.md > RELEASE.md
24+
- name: Create Release
25+
uses: ncipollo/release-action@v1
26+
id: create_release
27+
with:
28+
bodyFile: RELEASE.md
29+
tag: v${{ steps.info.outputs.version }}

0 commit comments

Comments
 (0)