Skip to content

Commit

Permalink
Merge main into upgrade-0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
antopalidi committed May 13, 2024
2 parents 90789ba + 7b49435 commit cbe3e10
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 200 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test-javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "[CI] JavaScript Tests"

on:
push:
branches:
- main
pull_request:

env:
CI: "true"
NODE_VERSION: 16.9.1

jobs:
test-report:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Get npm cache directory path
id: npm-cache-dir-path
run: echo "::set-output name=dir::$(npm get cache)-vocdoni"

- uses: actions/cache@v2
id: npm-cache
with:
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-
- run: npm ci
- run: npm run test
name: Node test
env:
CODECOV: 1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[CI] Tests"
name: "[CI] Ruby on Rails Tests"

on:
push:
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ruby RUBY_VERSION

# Inside the development app, the relative require has to be one level up, as
# the Gemfile is copied to the development_app folder (almost) as is.
base_path = ""
base_path = "../" if File.basename(__dir__) == "development_app"
require_relative "#{base_path}lib/decidim/vocdoni/version"

Expand Down
31 changes: 8 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ GEM
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.7)
bigdecimal (3.1.8)
bindex (0.8.1)
bootsnap (1.18.3)
msgpack (~> 1.2)
Expand Down Expand Up @@ -396,7 +396,7 @@ GEM
activesupport (>= 2)
nokogiri (>= 1.4)
htmlentities (4.3.4)
i18n (1.14.4)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
i18n-tasks (1.0.13)
activesupport (>= 4.0.2)
Expand Down Expand Up @@ -476,20 +476,10 @@ GEM
timeout
net-smtp (0.3.4)
net-protocol
nio4r (2.7.1)
nio4r (2.7.3)
node-runner (1.2.0)
nokogiri (1.16.4-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.4-arm-linux)
racc (~> 1.4)
nokogiri (1.16.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86-linux)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux)
racc (~> 1.4)
oauth (1.1.0)
oauth-tty (~> 1.0, >= 1.0.1)
snaky_hash (~> 2.0)
Expand Down Expand Up @@ -532,7 +522,7 @@ GEM
activerecord (>= 5.2)
request_store (~> 1.1)
parallel (1.24.0)
parallel_tests (4.7.0)
parallel_tests (4.7.1)
parallel
parser (3.3.0.5)
ast (~> 2.4.1)
Expand Down Expand Up @@ -675,7 +665,7 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.29.1)
rubocop-rspec (2.29.2)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
Expand All @@ -694,7 +684,7 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
selenium-webdriver (4.19.0)
selenium-webdriver (4.20.1)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
Expand Down Expand Up @@ -784,19 +774,14 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
bootsnap (~> 1.7)
byebug (~> 11.0)
codecov
decidim (>= 0.28, < 0.29)
decidim-dev (>= 0.28, < 0.29)
decidim (= 0.28.0)
decidim-dev (= 0.28.0)
decidim-vocdoni!
faker (~> 3.2)
i18n-tasks (~> 1.0)
Expand Down
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,29 @@ gem "decidim-vocdoni", github: "decidim-vocdoni/decidim-module-vocdoni"

And then execute:

```bash
```
bundle
bin/rails decidim_vocdoni:install:migrations
bin/rails decidim_vocdoni:webpacker:install
bin/rails decidim:upgrade
bin/rails db:migrate
```

> **EXPERTS ONLY**
>
> Under the hood, when running `bin/rails decidim:upgrade` the `decidim-vocdoni` gem will run the following (that can also be run manually if you consider):
>
> ```bash
> bin/rails decidim_vocdoni:install:migrations
> bin/rails decidim_vocdoni:webpacker:install
> ```
Depending on your Decidim version, you can choose the corresponding version to ensure compatibility:
| Version | Compatible Decidim versions |
|---------|-----------------------------|
| 1.x | 0.27.x |
| 2.x | 0.28.x |
## Cron based tasks
For some of the Elections status changes, you'll need to add a task to the schedule tasks
Expand Down Expand Up @@ -85,7 +94,7 @@ So, ensure you have a working Node.js application accessible by the Decidim inst
```json
{
"dependencies": {
"@vocdoni/sdk": "^0.5.3"
"@vocdoni/sdk": "^0.8.0"
}
}
```
Expand All @@ -94,10 +103,9 @@ So, ensure you have a working Node.js application accessible by the Decidim inst

The usage of the Vocdoni platform has some economic costs, as its using a Blockchain.

For using it in a production environment with guaranties, you need to contact the Decidim Association to vocdoni [at] decidim.org asking for a pricing. It depends in your usage (mostly in your census size).
For using it in a production environment with guaranties, you may contact with the maintaners of this plugin [PokeCode](https://pokecode.net) asking for a pricing. Costs will vary depending on your census size and the number of elections you want to perform.

As there could be other resellers and not only the Decidim Association, this needs to be configured through the ENV
variables: VOCDONI_RESELLER_NAME, VOCDONI_RESELLER_EMAIL
As there could be other resellers and not only the PokeCode, this needs to be configured through the ENV variables: VOCDONI_RESELLER_NAME, VOCDONI_RESELLER_EMAIL

## Configuration

Expand All @@ -107,12 +115,12 @@ Currently, the following ENV variables are supported:

| ENV variable | Description | Default value |
| ------------ | ----------- |-------|
| VOCDONI_API_ENDPOINT_ENV | The environment of the Vocdoni API. Only two values are accepted: `dev`, `stg`. Read more on [Vocdoni SDK Usage Environment](https://github.com/vocdoni/vocdoni-sdk#environment) | `stg` |
| VOCDONI_API_ENDPOINT_ENV | The environment of the Vocdoni API. Only two values are accepted: `dev`, `stg`, `prod`. Read more on [Vocdoni SDK Usage Environment](https://github.com/vocdoni/vocdoni-sdk#environment) | `stg` |
| VOCDONI_MINUTES_BEFORE_START | How many minutes should the setup be run before the election starts (when configured automatically) | `10` |
| VOCDONI_MANUAL_START_DELAY | How many seconds after the action of starting an election manually people will be allowed to vote. Note that this time is needed in order to configure the election in the blockchain. You might want to increase it if communication with the Vocdoni API is slow. | `30` |
| DECIDIM_VOCDONI_SDK_DEBUG | This is for development purposes. If set to `true`, any call to the Vocdoni API using the SDK ruby wrapper will be logged into the `node_debug.log` file (on the application main folder). | `false` |
| VOCDONI_RESELLER_NAME | The name of the Vocdoni reseller, the organization that manages the tokens to work with the Vocdoni platform. | `Decidim Association` |
| VOCDONI_RESELLER_EMAIL | The email of the Vocdoni reseller. | vocdoni@decidim.org |
| VOCDONI_RESELLER_NAME | The name of the Vocdoni reseller, the organization that manages the tokens to work with the Vocdoni platform. | `PokeCode SL` |
| VOCDONI_RESELLER_EMAIL | The email of the Vocdoni reseller. | vocdoni@pokecode.net |

It is also possible to configure the module using the `decidim-vocdoni` initializer:

Expand Down Expand Up @@ -228,6 +236,14 @@ can add these environment variables to the root directory of the project in a
file named `.rbenv-vars`. In this case, you can omit defining these in the
commands shown above.

We also have some tests for the Javascript code. To run them, you can use the
following commands:

```bash
npm ci
npm run test
```

### Test code coverage

Code coverage report is generated automatically after running the test suite, in a folder
Expand Down
1 change: 1 addition & 0 deletions app/packs/src/decidim/vocdoni/admin/steps/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const WAIT_TIME_MS = 30000;
// Fetch the votes from the API
export const getElectionResults = async () => {
const vocdoniClientElement = document.querySelector(".js-vocdoni-client");

if (!vocdoniClientElement || !vocdoniClientElement.dataset.resultsPath) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion app/packs/src/decidim/vocdoni/voter/setup-vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const submitVote = async (options) => {
// TODO: we should pinpoint what exactly is the culprit of this issue
// and if it's a bug in the SDK, we should fix it there
switch (options.env) {
case "prd":
case "prod":
client.url = "https://api.vocdoni.io/v2";
break;
case "stg":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="hide js-vocdoni-credits-collect-faucet-tokens-section">
<div class="callout alert">
<p>
<%= t("warning", scope: "decidim.vocdoni.admin.steps.credits") %>
<%= t("warning", scope: "decidim.vocdoni.admin.steps.credits") %>
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAnswersCountToDecidimVocdoniQuestions < ActiveRecord::Migration[6.1]
def change
add_column :decidim_vocdoni_questions, :answers_count, :integer, default: 0, null: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddVersionsCountToDecidimVocdoniAnswers < ActiveRecord::Migration[6.1]
def change
add_column :decidim_vocdoni_answers, :versions_count, :integer, default: 0, null: false
end
end
10 changes: 2 additions & 8 deletions lib/decidim/vocdoni.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,19 @@ module Vocdoni

# Public: Setting to configure the reseller name
config_accessor :vocdoni_reseller_name do
ENV.fetch("VOCDONI_RESELLER_NAME", "Decidim Association")
ENV.fetch("VOCDONI_RESELLER_NAME", "PokeCode SL")
end

# Public: Setting to configure the reseller email
config_accessor :vocdoni_reseller_email do
ENV.fetch("VOCDONI_RESELLER_EMAIL", "vocdoni@decidim.org")
ENV.fetch("VOCDONI_RESELLER_EMAIL", "vocdoni@pokecode.net")
end

# Public: Returns the API endpoint URL based on the environment specified in the configuration.
def self.api_endpoint_url
API_ENDPOINTS[api_endpoint_env]
end

def self.api_endpoint_env
return "stg" if config.api_endpoint_env.downcase == "stg"

"dev"
end

def self.explorer_vote_domain
"#{api_endpoint_env}.explorer.vote"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/decidim/vocdoni/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
# This holds the decidim-meetings version.
module Vocdoni
DECIDIM_VERSION = [">= 0.28", "< 0.29"].freeze
DECIDIM_VERSION = "0.28.0"
DECIDIM_COMPAT_VERSION = ">= 0.28"

def self.version
Expand Down
13 changes: 13 additions & 0 deletions lib/tasks/vocdoni_upgrade_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

Rake::Task["decidim:webpacker:install"].enhance do
Rake::Task["decidim_vocdoni:webpacker:install"].invoke
end

Rake::Task["decidim:choose_target_plugins"].enhance do
ENV["FROM"] = "#{ENV.fetch("FROM", nil)},decidim_vocdoni"
end

Rake::Task["decidim:webpacker:upgrade"].enhance do
Rake::Task["decidim_vocdoni:webpacker:install"].invoke
end
Loading

0 comments on commit cbe3e10

Please sign in to comment.