Skip to content

GSA/Challenge_gov

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
July 19, 2023 22:44
August 28, 2023 21:03
September 27, 2023 07:19
January 10, 2021 13:38
January 31, 2022 16:07
lib
August 28, 2023 21:03
February 25, 2020 14:04
March 25, 2020 12:56
March 6, 2019 12:41
August 26, 2023 02:50
March 6, 2019 13:19
February 13, 2020 09:56
November 7, 2022 17:06
November 7, 2022 17:06

ChallengeGov

GSA

Welcome to the ChallengeGov Data Portal

Requirements

Install & Setup

Requirements

Install PostgreSQL according to your OS of choice, for MacOS Postgres.app is recommended.

Alternatively, use the Challenge_gov docker-compose file to run psql locally in a container.

docker-compose run --service-ports psql

To install Elixir, Erlang, and NodeJS it is recommended to use the asdf version manager. Install instructions are copied here for MacOS, for other OSs see asdf docs. This also assumes you have HomeBrew installed.

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.0
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile

brew install \
  coreutils automake autoconf openssl \
  libyaml readline libxslt libtool unixodbc

Once asdf is set up, install each language. NodeJS may require setting up keys, and should display help to guide you.

asdf plugin-add erlang
asdf install erlang 21.2.5

asdf plugin-add elixir
asdf install elixir 1.8.0

asdf plugin-add nodejs
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf install nodejs 11.13.

asdf plugin-add yarn 
asdf install yarn 1.22.5

ChallengeGov Setup

Create the file config/dev.local.exs and set a secret key base, and if needed, include local PostgreSQL connection information. It will look something like (replacing with your local configuration):

use Mix.Config

config :challenge_gov, Web.Endpoint,
  secret_key_base: "<OUTPUT OF `mix phx.gen.secret`>"

config :challenge_gov, ChallengeGov.Repo,
  username: "postgres",
  password: "postgres",
  database: "challenge_gov_dev",
  hostname: "localhost",
  pool_size: 10

Create the file config/test.local.exs and set a secret key base, and if needed, include local PostgreSQL connection information. It will look something like (replacing with your local configuration):

use Mix.Config

config :challenge_gov, Web.Endpoint,
  secret_key_base: "<OUTPUT OF `mix phx.gen.secret`>"

config :challenge_gov, ChallengeGov.Repo,
  username: "postgres",
  password: "postgres",
  database: "challenge_gov_test",
  hostname: "localhost",
  pool_size: 10

Start with cloning the application. Once cloned, in your terminal run the following commands inside the cloned folder.

mix local.hex --force
mix local.rebar --force
mix deps.get
mix compile

This sets up your basic elixir environment. Next setup the database. The following commands will create and migrate locally, as well as migrate seeds.

Super-Admin (optional) -- If you would like to seed the database with a default super-admin user, please set the following environment variables:

  • FIRST_USER_EMAIL
  • FIRST_USER_FN
  • FIRST_USER_LN

Setup and seed the database

mix ecto.create
mix ecto.migrate
mix run priv/repo/seeds_updated.exs

Once the database is setup, make sure to install javascript dependencies.

cd assets/
yarn
cd ..

Now you can run the server.

mix phx.server

Development

Gain access to the portal by going to http://localhost:4000/ and clicking on 'Dev Accounts' to select and sign in under different user roles.

Testing

The ChallengeGov runs each pull request (and every commit on the master branch) through CI. Make sure to add tests as you extend the application. We also run Credo and the built in formatter in CI to ensure code quality.

Deployment

Passing CI on master deploys to the dev environment via Cloud Foundry as part of the Drone build.

Importing Data

Run importers in order of Open, Closed, ClosedImported. Afterward set the challlenges_seq_id to the max challenge-id.

Commands to run:

$ iex -S mix run
> Mix.Tasks.OpenChallengeImporter.run("")
> Mix.Tasks.ClosedChallengeImporter.run("")
> Mix.Tasks.ClosedImportedChallengeImporter.run("")

In psql after imports:

SELECT setval('challenges_id_seq', max(id)) FROM challenges;

Learn more about Phoenix