-
Notifications
You must be signed in to change notification settings - Fork 52
148 lines (125 loc) · 6.03 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Continuous Integration
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
linting:
if: github.event.pull_request && (github.triggering_actor != 'dependabot[bot]')
runs-on: ubuntu-latest
env:
PRONTO_PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
steps:
- name: checkout repository
uses: actions/checkout@v4
- run: |
git fetch --no-tags --prune --unshallow origin +refs/heads/*:refs/remotes/origin/*
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.0'
- name: install linting dependencies
run: gem install rubocop pronto pronto-rubocop rubocop-rspec rubocop-rails rubocop-performance
- name: run Pronto
run: pronto run -f github_status github_pr_review -c origin/${{ github.base_ref }}
env:
PRONTO_GITHUB_ACCESS_TOKEN: "${{ github.token }}"
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name # don't run on PRs from forks because of missing write permission: https://github.com/orgs/community/discussions/26829
- name: run Pronto on fork
# We cannot use the `github_status` formatter on forks in order to report the linting status,
# since the formatter requires write access, which isn't the default on forks.
# This is why we're using the `--exit-code` flag, which causes Pronto to propagate non-zero exit codes,
# i.e., we can use the `--exit-code` flag to fail the linting job in case Pronto reports warning or errors (https://github.com/prontolabs/pronto).
run: pronto run --exit-code -f text -c origin/${{ github.base_ref }}
if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
testing:
needs: [linting]
if: always() && (needs.linting.result == 'success' || needs.linting.result == 'skipped') # https://github.com/actions/runner/issues/491
runs-on: ubuntu-latest
defaults:
run:
shell: bash
container: complat/chemotion_eln_runner:main
services:
postgres:
image: postgres:16 # https://hub.docker.com/_/postgres
env:
POSTGRES_PASSWORD: postgres # env variable required by postgres Docker container
POSTGRES_USER: chemotion # optional env variable used in conjunction with POSTGRES_PASSWORD to set a user and their password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: create user for datacollectors testing
run: |
useradd testuser -m -s /bin/bash
mkdir /home/testuser/.ssh
chown testuser:testuser /home/testuser/.ssh
chmod 700 /home/testuser/.ssh
- name: configure ssh for datacollectors testing
run: |
service ssh restart
mkdir -p $HOME/.ssh
chmod 700 $HOME/.ssh
ssh-keygen -t ed25519 -f $HOME/.ssh/id_test -N ""
# echo "$(<$HOME/.ssh/id_test.pub)" >> $HOME/.ssh/authorized_keys
echo "$(<$HOME/.ssh/id_test.pub)" | sudo tee -a /home/testuser/.ssh/authorized_keys
eval `ssh-agent`
ssh-add $HOME/.ssh/id_test
ssh-keyscan -H 127.0.0.1 >> $HOME/.ssh/known_hosts
- name: configure repository
run: |
mv public/welcome-message-sample.md public/welcome-message.md
cd config
cp database.yml.gitlab database.yml
cp -f datacollectors.yml.example datacollectors.yml
cp -f profile_default.yml.example profile_default.yml
cp -f shrine.yml.example shrine.yml
cp -f storage.yml.example storage.yml
cp -f radar.yml.example radar.yml
touch klasses.json
bundle config set without ''
- name: configure postgres
env:
PG_ROLE: chemotion_test
PG_ROLE_PASSWORD: 123456
PG_DATABASE: chemotion_test
PGPASSWORD: postgres # env variable required by psql client
run: | # host is service container name
psql -h postgres -U chemotion -c "CREATE ROLE $PG_ROLE LOGIN CREATEDB NOSUPERUSER PASSWORD '$PG_ROLE_PASSWORD';"
psql -h postgres -U chemotion -c "CREATE DATABASE $PG_DATABASE OWNER $PG_ROLE;"
psql -d postgresql://$PG_ROLE:$PG_ROLE_PASSWORD@postgres/$PG_DATABASE -c 'CREATE EXTENSION IF NOT EXISTS "pg_trgm"; CREATE EXTENSION IF NOT EXISTS "hstore"; CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
- name: bundle install
run: bundle install
- name: yarn install
run: yarn install --production=false
- name: prepare postgres
run: |
RAILS_ENV=test bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:test:prepare
RAILS_ENV=test bundle exec rake db:seed
- name: npm test
run: npm test
- name: rspec unit
run: |
eval `ssh-agent`
ssh-add $HOME/.ssh/id_test
RAILS_ENV=test bundle exec rspec --exclude-pattern spec/{features}/**/*_spec.rb spec
- name: coverage rspec unit
if: github.event.pull_request && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) && (github.triggering_actor != 'dependabot[bot]') # don't run on PRs from forks because of missing write permission: https://github.com/orgs/community/discussions/26829
uses: zgosalvez/github-actions-report-lcov@v1
with:
coverage-files: coverage/lcov/${{ github.event.repository.name }}.lcov
minimum-coverage: 57
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
# - name: precompile
# run: RAILS_ENV=test bundle exec rake webpacker:compile
# - name: rspec acceptance
# continue-on-error: true # don't fail job because this step; TODO: fix flaky acceptance tests...
# run: RAILS_ENV=test bundle exec rspec spec/features