# Gras Delivery Script

### Setup

##### 1. Github Token
To install some private packages, you need to be able to authenticate with Github.

* Create Github access token [here](https://github.com/settings/tokens) with all **repo** scope only.
* Set auth token as environment variable
```bash
export COMPOSER_AUTH='{"github-oauth": {"github.com": "<YOUR-GITHUB-TOKEN-HERE>"}}'
```

##### 2. Database Credentials

* Create `.env` file
```bash
cp .env.shadow .env
```
* Enter **qa** values in `.env` for
  * DD_USER
  * DD_PASS
  * AR_USER
  * AR_PASS

##### 3. AWS Credentials

* Setup [awsume](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f#5618a9119254428e9baeada414767e85) and activate a profile that has access to the prod account using MFA.
* Install [ecr-credentials-helper](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f#ad5d3a529a7d41b299daa604c517ebf2) to automatically use your configured AWS credentials when pulling down ECR images.

### Running

```bash
docker compose run --rm --build gras-delivery
```

## Linting and Testing

Run the full lint and test suite (PHP syntax check, PHPCodeSniffer, PHPStan, yamllint, PHPUnit):

```bash
docker compose run --rm --build lint-and-test
```

To skip linting and run tests only:

```bash
SKIP_LINT=1 docker compose run --rm --build lint-and-test
```

## Update the lockfile


```bash
docker compose run --rm --build update-lockfile
```

### Tools

| Tool | Config file | Purpose |
|---|---|---|
| PHP CodeSniffer | `phpcs.xml` | PSR-12 code style |
| PHPStan | `phpstan.neon.dist` | Static analysis (level 5) |
| yamllint | `.yamllint` | YAML file validation |
| PHPUnit | `phpunit.xml` | Unit tests (`tests/`) |

