Skip to content

Commit

Permalink
Merge pull request #22 from CivicTechTO/edge
Browse files Browse the repository at this point in the history
sync with Edge
  • Loading branch information
NewJerseyStyle authored Oct 11, 2024
2 parents f59e20d + ca385f3 commit d81ef5f
Show file tree
Hide file tree
Showing 35 changed files with 2,353 additions and 1,194 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/bundlewatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Client components all use this version
- name: Use Node version for app builds
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -37,7 +37,7 @@ jobs:
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Restore npm cache directory
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
56 changes: 35 additions & 21 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,57 @@ concurrency:

on:
push:
branches: [edge]
paths-ignore: ["**.md"]
branches:
- edge
paths-ignore:
- "**.md"

pull_request:
paths-ignore: ["**.md"]
paths-ignore:
- "**.md"

jobs:
cypress-run:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and Run Application
uses: isbang/[email protected]
with:
compose-file: |
docker-compose.yml
docker-compose.test.yml
compose-flags: "--env-file test.env"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and start Docker containers
run: |
docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env --profile postgres up -d --build
- name: Check Application Health
uses: jtalk/url-health-check-action@v3
- name: Health Check the Server http response
uses: jtalk/url-health-check-action@v4
with:
url: http://localhost/api/v3/testConnection
max-attempts: 10
retry-delay: 10s

- name: Dump Application Logs
if: failure()
run: |
echo "Health check failed. Dumping Docker logs..."
docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env logs
- name: Cypress Run
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
config: baseUrl=http://localhost
spec: cypress/e2e/!(third-party)/**/*.cy.js
working-directory: e2e

- name: Upload Cypress screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: e2e/cypress/screenshots

- name: Upload Cypress videos
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: e2e/cypress/videos

- name: Stop Docker containers
if: always()
run: docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env --profile postgres down
6 changes: 3 additions & 3 deletions .github/workflows/depcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
echo "name=HAS_SECRET" >> $GITHUB_ENV
- name: Use Node.js
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v4
with:
node-version: 14.4.0
node-version: 18

# See: https://github.com/taskworld/commit-status
- name: Install commit-status CLI tool
Expand All @@ -39,7 +39,7 @@ jobs:
commit-status pending "DepCheck / dependencies" "Detecting unused packages..."
commit-status pending "DepCheck / devDependencies" "Detecting unused packages..."
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4

- name: Install depcheck CLI tool
run: npm install -g depcheck
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v4
with:
node-version: 14.4.0
node-version: 18

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Restore npm cache directory
uses: actions/cache@v2.1.5
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches:
- main
- dev
- edge
pull_request:
branches:
- main
Expand All @@ -26,9 +26,9 @@ jobs:
id: extract_branch

- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v4
with:
ref: ${{ steps.extranct_branch.outputs.branch }}
ref: ${{ steps.extract_branch.outputs.branch }}

- name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -42,7 +42,7 @@ jobs:
mv example.env .env
sed -i 's/docker.io/ghcr.io/g' docker-compose.yml
sed -i 's/compdem/civictechto/g' docker-compose.yml
docker compose build --parallel --build-arg GIT_HASH=${GITHUB_SHA:0:6}
docker compose --profile postgres build --parallel --build-arg GIT_HASH=${GITHUB_SHA:0:6}
- name: Push images to Docker Hub
run: docker compose push --ignore-push-failures
run: docker compose --profile postgres push --ignore-push-failures
6 changes: 3 additions & 3 deletions .github/workflows/test-clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
test-clj:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4

- name: Prepare java
uses: actions/setup-java@v2.5.0
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 16.0.2

- name: Install Clojure tooling
uses: DeLaGuardo/setup-clojure@3.7
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 1.10.1.693

Expand Down
35 changes: 26 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 1.0

## [unreleased]
Landmark!

### Changed
- Improved docs for configuring comment translation. [`#319`][]
After 12 years of research and development, we are making this our first versioned release of the Polis platform!

This version signifies a turning point for the project, where we see the core methodology as stable, and wish to facilitate the growing need for coordination and transparency among an increasing number of partners, but also to free ourselves to continue innovating at the cutting edge of deliberative technology (e.g. [Opportunities and Risks](https://arxiv.org/abs/2306.11932) and [Coherent Mode](https://arxiv.org/abs/2211.12571)).

From here on out, we'll be maintaining two main branches of the Polis software:
* `stable`: points to the latest stable release of the software, after having passed QA assessment
* `edge`: the most recent version of the software to have been merged in, and ready (pending QA) for merging into `stable` (can be assumed to have passed automated testing criteria)

For now, the versioning scheme will look like: `major.minor[.patch]`.
In general, updates will look like:

* `patch`: bugfix; no intended behavior changed
* `minor`: new features, without major changes to the underlying algorithm, or significant interface changes (includes new translations or significant translation updates)
* `major`: significantly different default algorithmic behavior, participant interface, or other major new functionality

In general minor version bumps will be preferred over major if features don't by default effect either the algorithm or participation interface.
This allows us to build under feature flags before official release, giving us an opportunity to launch quickly, perform user testing, and iterate between major version releases as features solidify.

Changes which have been merged to `edge` but are not yet versioned on `stable` can be listed at the "edge changes" section at the end of this living document as they are merged in after passing automated testing.


## edge changes

* ...

### Added
- Added support for configuring comment translation credentials via base64-encoded string, stored in `GOOGLE_CREDENTIALS_BASE64` envvar. [`#319`][]

[`#319`]: https://github.com/pol-is/polisServer/issues/319
39 changes: 30 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,44 @@
SHELL=/bin/bash
E2E_RUN = cd e2e;

define parse_env_value
$(shell grep -e ^$(1) ${ENV_FILE} | awk -F'[=]' '{gsub(/ /,"");print $$2}')
endef

define parse_env_bool
$(if $(filter false,$(1)),false,true)
endef

# Default environment and settings (dev)
export ENV_FILE = .env
export TAG = $(shell grep -e ^TAG ${ENV_FILE} | awk -F'[=]' '{gsub(/ /,""); print $$2}')
export TAG = $(call parse_env_value,TAG)
export GIT_HASH = $(shell git rev-parse --short HEAD)
POSTGRES_DOCKER_RAW = $(shell echo $(call parse_env_value,POSTGRES_DOCKER) | tr '[:upper:]' '[:lower:]')
export POSTGRES_DOCKER = $(call parse_env_bool,$(POSTGRES_DOCKER_RAW))

# Default compose file args
export COMPOSE_FILE_ARGS = -f docker-compose.yml -f docker-compose.dev.yml
COMPOSE_FILE_ARGS += $(if $(POSTGRES_DOCKER),--profile postgres,)

# Set up environment-specific values
define setup_env
$(eval ENV_FILE = $(1))
$(eval TAG = $(call parse_env_value,TAG))
$(eval POSTGRES_DOCKER_RAW = $(shell echo $(call parse_env_value,POSTGRES_DOCKER) | tr '[:upper:]' '[:lower:]'))
$(eval POSTGRES_DOCKER = $(call parse_env_bool,$(POSTGRES_DOCKER_RAW)))
$(eval COMPOSE_FILE_ARGS = $(2))
$(eval COMPOSE_FILE_ARGS += $(if $(POSTGRES_DOCKER),--profile postgres,))
endef

PROD: ## Run in prod mode (e.g. `make PROD start`, etc.) using config in `prod.env`
$(eval ENV_FILE = prod.env)
$(eval TAG = $(shell grep -e ^TAG ${ENV_FILE} | awk -F'[=]' '{gsub(/ /,"");print $$2}'))
$(eval COMPOSE_FILE_ARGS = -f docker-compose.yml)
PROD:
$(call setup_env,prod.env,-f docker-compose.yml)

TEST: ## Run in test mode (e.g. `make TEST e2e-run`, etc.) using config in `test.env`
$(eval ENV_FILE = test.env)
$(eval TAG = $(shell grep -e ^TAG ${ENV_FILE} | awk -F'[=]' '{gsub(/ /,"");print $$2}'))
$(eval COMPOSE_FILE_ARGS = -f docker-compose.yml -f docker-compose.test.yml)
TEST:
$(call setup_env,test.env,-f docker-compose.yml -f docker-compose.test.yml)

echo_vars:
@echo ENV_FILE=${ENV_FILE}
@echo POSTGRES_DOCKER=${POSTGRES_DOCKER}
@echo TAG=${TAG}

pull: echo_vars ## Pull most recent Docker container builds (nightlies)
Expand Down
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ For a detailed methods paper, see [Polis: Scaling Deliberation by Mapping High D

<!-- Changes to badge text in URLs below, require changes to "name" value in .github/workflows/*.yml -->
[![Docker Image Builds](https://github.com/CivicTechTO/polis/workflows/Docker%20image%20builds/badge.svg)][docker-image-builds]
<!-- [![E2E Tests](https://github.com/compdemocracy/polis/workflows/E2E%20Tests/badge.svg)][e2e-tests] -->
[![E2E Tests](https://github.com/CivicTechTO/polis/workflows/E2E%20Tests/badge.svg)][e2e-tests]

[docker-image-builds]: https://hub.docker.com/u/newjerseystyle
<!-- [e2e-tests]: https://github.com/compdemocracy/polis/actions?query=workflow%3A%22E2E+Tests%22 -->
[e2e-tests]: https://github.com/CivicTechTO/polis/actions?query=workflow%3A%22E2E+Tests%22

---

Expand Down Expand Up @@ -77,7 +77,7 @@ cp example.env .env


```sh
docker compose up --build
docker compose --profile postgres up --build
```

If you get a permission error, try running this command with `sudo`.
Expand All @@ -87,7 +87,7 @@ To avoid having to use `sudo` in the future (on a Linux or Windows machine with
Once you've built the docker images, you can run without `--build`, which may be faster. Run

```sh
docker compose up
docker compose --profile postgres up
```

or simply
Expand All @@ -103,16 +103,22 @@ If you have only changed configuration values in .env, you can recreate your con
fully rebuilding them with `--force-recreate`. For example:

```sh
docker compose down
docker compose up --force-recreate
docker compose --profile postgres down
docker compose --profile postgres up --force-recreate
```

To see what the environment of your containers is going to look like, run:

```sh
docker compose convert
docker compose --profile postgres convert
```

#### Using a local or remote (non-docker) database

Omit the `--profile postgres` flag to use a local or remote database. You will need to set the `DATABASE_URL` environment variable in your `.env` file to point to your database.

When using `make` commands, setting POSTGRES_DOCKER to `true` or `false` will determine whether to automatically include `--profile postgres` when it calls out to `docker compose`.

#### Production Mode Shortcuts

The commands in the Makefile can be prefaced with PROD. If so, the "dev overlay" configuration in `docker-compose.dev.yml` will be ignored.
Expand All @@ -138,8 +144,8 @@ You can now test your setup by visiting `http://localhost:80/home`.
Once the index page loads, you can create an account using the `/createuser` path.
You'll be logged in right away; email validation is not required.

When you're done working, you can end the process using `Ctrl+C`, or typing `docker compose down`
if you are running in "detched mode".
When you're done working, you can end the process using `Ctrl+C`, or typing `docker compose --profile postgres down`
if you are running in "detached mode".

### Updating the system

Expand Down Expand Up @@ -174,7 +180,7 @@ However, if you are deploying in a high impact context and need help, please [re
Once you've gotten [Polis running (as described above)](#-running-polis), you can enable developer conveniences by running

```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml up
docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile postgres up
```

(run with `--build` if this is your first time running, or if you need to rebuild containers)
Expand All @@ -188,7 +194,7 @@ This enables:
- etc.

This command takes advantage of the `docker-compose.dev.yml` _overlay_ file, which layers the developer conveniences describe above into the base system, as described in the `docker-compose.yml` file.
You can specify these `-f docker-compose.yml -f docker-compose.dev.yml` arguments for any `docker` command which you need to take advantage of these features (not just `docker compose up`).
You can specify these `-f docker-compose.yml -f docker-compose.dev.yml` arguments for any `docker` command which you need to take advantage of these features (not just `docker compose --profile postgres up`).

You can create your own `docker-compose.x.yml` file as an overlay and add or modify any values you need to differ
from the defaults found in the `docker-compose.yml` file and pass it as the second argument to the `docker compose -f` command above.
Expand Down Expand Up @@ -219,7 +225,7 @@ git config --local include.path ../.gitconfig

#### Running as a background process

If you would like to run docker compose as a background process, run the `up` commands with the `--detach` flag, and use `docker compose down` to stop.
If you would like to run docker compose as a background process, run the `up` commands with the `--detach` flag, and use `docker compose --profile postgres down` to stop.

#### Using Docker Machine as your development environment

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
Loading

0 comments on commit d81ef5f

Please sign in to comment.