Development Instructions (macOS Apple Silicon) - Pull-Request-Club/PRC GitHub Wiki

Installation

Get the repository.

git clone https://github.com/kyzn/PRC && cd PRC

Install dependencies.

# Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Then install memcached through brew
brew install memcached

# Also install openssl
brew install openssl
# Then add this to your profile (~/.bash_profile, ~/.bashrc, ~/.zshrc, whichever you use)
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
# Run these two to avoid "perl is loading libcrypto in an unsafe way" errors
sudo ln -s /opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib /usr/local/lib/libssl.dylib
sudo ln -s /opt/homebrew/opt/[email protected]/lib/libcrypto.1.1.dylib /usr/local/lib/libcrypto.dylib

# Get latest perl version via perlbrew
\curl -L https://install.perlbrew.pl | bash
perlbrew install -j 4 stable
perlbrew switch $(perlbrew list)
perlbrew install-cpanm

# Install CPAN deps
OPENSSL_PREFIX=/opt/homebrew/opt/[email protected] cpanm Net::SSLeay
cpanm Carton Starman App::Sqitch DBD::SQLite DDP LWP::Protocol::https JSON::XS

Here we're going to do one hack for Crypt::DES, for 2.07 install fails with DES.xs:39:3: error: implicit declaration of function 'perl_des_expand_key' is invalid in C99. This hack will not be needed when the module is updated for the -Wimplicit-function-declaration flag.

Go to a different directory, for example /tmp.

cd /tmp
git clone https://github.com/kyzn/Crypt-DES && cd Crypt-DES
# Install it once to perlbrew
perl Makefile.PL
make
make install
# And install it once to where "carton install" would install it. Update the path to your PRC directory.
mkdir ~/Projects/PRC/local
perl Makefile.PL INSTALL_BASE=~/Projects/PRC/local
make
make install

# And then install the rest with carton
cd ~/Projects/PRC
OPENSSL_PREFIX=/opt/homebrew/opt/[email protected] carton install

Database Setup

If you have an existing prc.db, bring it to sqitch/ folder. Otherwise, build from scratch: Leave it in sqitch/ folder.

cd sqitch && sqitch deploy db:sqlite:prc.db

Secrets

You will need a couple of secrets for some functions to work.

GitHub secrets

To make GitHub authentication work, you need to set up a GitHub app for Dev purposes.

Sendgrid secrets

If you want to see emails working, you need a SendGrid API key.

Encryption and HMAC keys

These are 128 bit keys that are used to encrypt unsubscribe links in emails. If you are not going to test emails it's not required. Otherwise just put 32 as.

Example

At the root of the project, create a secrets.yml file and put your secrets there. It should look like below:

Create a secrets.yml file at the root folder of the project that looks like below. CLIENT_ID and CLIENT_SECRET are for the GitHub app. ENC_KEY and HMAC_KEY are 128 bit keys, anything goes. SG_API_KEY is sendgrid key to test sending emails, it's not required otherwise.

CLIENT_ID: ....
CLIENT_SECRET: ....
ENC_KEY: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
HMAC_KEY: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SG_API_KEY: ....

Run

Run memcached

memcached start -d

Then run the app locally

DBIC_TRACE=1 carton exec script/prc_server.pl -r -d