Skip to content

Commit

Permalink
Merge pull request #608 from alphagov/meta-docker
Browse files Browse the repository at this point in the history
Use GOV.UK Docker to test GOV.UK Docker
  • Loading branch information
benthorner authored Jun 28, 2022
2 parents 85384e4 + 0f6050b commit 32244e2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
key: bundle-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: bundle
- run: bundle install --jobs 4 --retry 3 --deployment
- run: GOVUK_DOCKER_DIR=. make lint test
- run: GOVUK_DOCKER_DIR=. make test-ci
1 change: 0 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
brew "dnsmasq"
brew "rbenv"
brew "pv"
brew "shellcheck"

Expand Down
16 changes: 9 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ Contributions welcome - just raise a PR and make sure the tests pass!

## Testing

**First make sure you have the following dependencies.**
GOV.UK Docker tests are written in Ruby / RSpec. Just like any other Ruby project, we have a `govuk-docker-lite` stack for running the tests, using GOV.UK Docker.

- [rbenv](https://github.com/rbenv/rbenv#installation)

**Next install Ruby / dependencies and run all the tests.**
Do this the first time you run the tests:

```sh
rbenv install
make govuk-docker
```

bundle install
Do this to run the tests for GOV.UK Docker:

make test
```sh
make test-local
```

This will also run checks on scripts and config files in this repo. Since these checks require access to your local machine, they are not run using GOV.UK Docker.

## Versioning

GOV.UK Docker is [versioned][version] in order to notify users about important changes, where they may need to take action. Since we use the repo itself for distributing GOV.UK Docker, for many PRs it's unlikely you will need to change the version.
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ default:
@echo "For example:"
@echo " make content-publisher"

lint:
# Lint the ruby code
bundle exec rubocop
test-local: test-scripts
$(GOVUK_DOCKER) run govuk-docker-lite bundle exec rubocop
$(GOVUK_DOCKER) run govuk-docker-lite bundle exec rspec

test:
# Run the tests for the govuk-docker CLI
test-ci: test-scripts
bundle exec rubocop
bundle exec rspec

test-scripts:
# Test that the docker-compose config is valid. This will error if there are errors
# in the YAML files, or incompatible features are used.
$(GOVUK_DOCKER) config > /dev/null
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Run `echo $SHELL` if you're not sure which shell you use. After saving, you will
```
git clone [email protected]:alphagov/govuk-docker.git
cd govuk-docker
bundle install
bin/setup
```

Expand Down
17 changes: 16 additions & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,27 @@ ssh_username: "yourname"
## Diagnose common issues when setting up GOV.UK Docker
Run the following command in `~/govuk/govuk-docker`. Since this script makes use of Ruby Gems, you will need to [install some additional dependencies](../CONTRIBUTING.md#testing) in order to do this.
Run the following command in `~/govuk/govuk-docker`.

```
bin/doctor
```
Since this script makes use of Ruby Gems, you will need to install some additional dependencies in order to do this.
First make sure you have the following dependencies:
- [rbenv](https://github.com/rbenv/rbenv#installation)
Next install Ruby / dependencies and run all the tests:
```sh
rbenv install
bundle install
```

## Diagnose database issues with a project/app not making

If you run `make` on an app inside govuk-docker and face any of the following database issues:
Expand Down
1 change: 1 addition & 0 deletions projects/generic-ruby-library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ govspeak: bundle-govspeak
govuk_app_config: bundle-govuk_app_config
plek: bundle-plek
smokey: bundle-smokey
govuk-docker: bundle-govuk-docker
4 changes: 4 additions & 0 deletions projects/generic-ruby-library/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ services:
<<: *generic-ruby-library
working_dir: /govuk/govuk_app_config

govuk-docker-lite:
<<: *generic-ruby-library
working_dir: /govuk/govuk-docker

plek-lite:
<<: *generic-ruby-library
working_dir: /govuk/plek
Expand Down

0 comments on commit 32244e2

Please sign in to comment.