Skip to content

Commit

Permalink
Pin plugins to specific commits (#125)
Browse files Browse the repository at this point in the history
* Pin plugins to specific commits

* Save lockfiles for plugins during image creation

* Try to handle GEM_HOME issues

* Revisit pinned commits, install all gems at the root of the app

* Fixes

* Moar fixes!

* Add missing bundler config

* Ignore license warning in bundler config for ROCK

* Revert "feat(runners): Use edge runners (#119)"

This reverts commit e712459.

* Fix rexml patch

* Upgrade nodejs version

---------

Co-authored-by: Tom Haddon <[email protected]>
  • Loading branch information
nrobinaubertin and Tom Haddon committed Oct 24, 2023
1 parent 21d13a7 commit ba058cc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ jobs:
unit-tests:
uses: canonical/operator-workflows/.github/workflows/test.yaml@main
secrets: inherit
with:
self-hosted-runner: true
self-hosted-runner-label: "edge"
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ header:
- 'LICENSE'
- 'trivy.yaml'
- 'zap_rules.tsv'
- 'discourse_rock/bundler/config'
- 'discourse_rock/patches/**'
- 'lib/**'
comment: on-failure
6 changes: 6 additions & 0 deletions discourse_rock/bundler/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
BUNDLE_ALLOW_OFFLINE_INSTALL: "true"
BUNDLE_CACHE_ALL: "true"
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_FROZEN: "true"
BUNDLE_DISABLE_VERSION_CHECK: "true"
30 changes: 25 additions & 5 deletions discourse_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ parts:
plugin: nil
source: .
build-environment:
- NODE_VERSION: "18.17.1"
- NODE_VERSION: "18.18.2"
- ARCH: "x64"
overlay-script: |
node_uri="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.gz"
Expand Down Expand Up @@ -94,8 +94,8 @@ parts:
get-solved-plugin-source:
plugin: dump
source: https://github.com/discourse/discourse-solved.git
source-commit: e6cce5486df906ede74aa1b17ab308a145a99b88
source-depth: 1
source-commit: d6c8089ca38611b09a8edb29d64f359bcef11f11
after:
- get-discourse
organize:
Expand All @@ -105,6 +105,7 @@ parts:
after:
- get-discourse
source: https://github.com/canonical-web-and-design/discourse-markdown-note.git
source-commit: f4426d5929de067f123659dc690e9438a324817a
source-depth: 1
organize:
"*": srv/discourse/app/plugins/discourse-markdown-note/
Expand All @@ -113,6 +114,7 @@ parts:
after:
- get-discourse
source: https://github.com/unfoldingWord-dev/discourse-mermaid.git
source-commit: 341e1b08608ed0262bae6dffded2eddfae91f67a
source-depth: 1
organize:
"*": srv/discourse/app/plugins/discourse-mermaid/
Expand All @@ -121,6 +123,7 @@ parts:
after:
- get-discourse
source: https://github.com/discourse/discourse-saml.git
source-commit: 15a8274bbec438768fb020d4f20462db476b0f29
source-depth: 1
override-build: |
craftctl default
Expand All @@ -132,12 +135,22 @@ parts:
after:
- get-discourse
source: https://github.com/discourse/discourse-prometheus.git
source-commit: 72fff206ba18ad5ca3112fed2f5f0ce6a17ca6f8
source-depth: 1
override-build: |
craftctl default
grep -e ^gem plugin.rb >> Gemfile
organize:
"*": srv/discourse/app/plugins/discourse-prometheus/
get-data-explorer:
plugin: dump
after:
- get-discourse
source: https://github.com/discourse/discourse-data-explorer.git
source-commit: e7c19ac107dcd37618c7ac7b98530e99c7fe31db
source-depth: 1
organize:
"*": srv/discourse/app/plugins/discourse-data-explorer/
get-patches:
plugin: dump
source: patches
Expand All @@ -157,13 +170,20 @@ parts:
# https://github.com/lautis/uglifier/issues/127#issuecomment-352224986
sed -i 's/config.assets.js_compressor = :uglifier/config.assets.js_compressor = Uglifier.new(:harmony => true)/g' srv/discourse/app/config/environments/production.rb
sed -i '1s/^/require "uglifier"\n/' srv/discourse/app/config/environments/production.rb
get-bundler-config:
plugin: dump
source: bundler
organize:
"*": srv/discourse/app/.bundle/
install-gems:
plugin: nil
after:
- get-discourse
- get-saml-plugin-source
- get-prometheus-plugin-source
- get-data-explorer
- apply-patches
- get-bundler-config
build-packages:
- libpq-dev
- ruby2.7
Expand All @@ -175,11 +195,11 @@ parts:
gem install -n "bin" bundler
# rexml version is forced to avoid conflicting transient dependency issue
sed -i 's/rexml (3.2.5)/rexml (3.2.6)/' Gemfile.lock
# rexml version is forced to avoid conflicting transient dependency issue
echo "gem 'rexml', '3.2.6'" >> Gemfile
# The following is a fix for https://github.com/discourse/discourse-prometheus/blob/72fff206ba18ad5ca3112fed2f5f0ce6a17ca6f8/plugin.rb#L13C1-L13C105
sed -i "s/gem 'prometheus_exporter', .*/gem 'prometheus_exporter', '0.5.0'/g" Gemfile
bin/bundle install
bin/bundle install --gemfile="plugins/discourse-saml/Gemfile"
bin/bundle install --gemfile="plugins/discourse-prometheus/Gemfile"
bin/bundle install --gemfile="plugins/discourse-saml/Gemfile"
organize:
'/var/lib/gems': var/lib/gems
'srv/discourse/app/bin/*': srv/discourse/app/bin/
Expand Down
3 changes: 2 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ def _create_discourse_environment_settings(self) -> typing.Dict[str, str]:
"DISCOURSE_SMTP_PASSWORD": self.config["smtp_password"],
"DISCOURSE_SMTP_PORT": str(self.config["smtp_port"]),
"DISCOURSE_SMTP_USER_NAME": self.config["smtp_username"],
"GEM_HOME": "/var/lib/gems/2.7.0",
"GEM_HOME": "/var/lib/gems/2.7.0/",
"GEM_PATH": "/var/lib/gems/2.7.0/",
"RAILS_ENV": "production",
}
pod_config.update(self._get_saml_config())
Expand Down

0 comments on commit ba058cc

Please sign in to comment.