Skip to content

Commit

Permalink
Use the optimade container image as a service (#107)
Browse files Browse the repository at this point in the history
Use the `optimade` container image as a service instead of
running docker-compose in CI.

Add OPIMADE_BASE_URL env variable with `gh_actions_host`
as domain host.

Update README about using `services`.
  • Loading branch information
CasperWA committed May 16, 2022
1 parent 36de133 commit 7e620d8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 44 deletions.
99 changes: 56 additions & 43 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ jobs:
validator_regular:
runs-on: ubuntu-latest
name: Regular server

services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213

steps:
- uses: actions/checkout@v3

- name: Set up and run regular server
run: |
git clone --recurse-submodules https://github.com/Materials-Consortia/optimade-python-tools
docker-compose -f ./optimade-python-tools/docker-compose.yml up optimade &
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
- name: Run action (validating the unversioned path)
uses: ./
with:
Expand All @@ -93,16 +95,19 @@ jobs:
validator_index:
runs-on: ubuntu-latest
name: Index server

services:
optimade_index:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3214:5000
env:
MAIN: main_index
OPTIMADE_BASE_URL: http://gh_actions_host:3214

steps:
- uses: actions/checkout@v3

- name: Set up and run index server
run: |
git clone --recurse-submodules https://github.com/Materials-Consortia/optimade-python-tools
docker-compose -f ./optimade-python-tools/docker-compose.yml up optimade-index &
.github/utils/wait_for_it.sh localhost:3214 -t 120
sleep 15
- name: Run action
uses: ./
with:
Expand All @@ -113,16 +118,18 @@ jobs:
all_versioned_paths:
runs-on: ubuntu-latest
name: All versioned paths for regular server

services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213

steps:
- uses: actions/checkout@v3

- name: Set up and run regular server (which includes all versioned base URLs)
run: |
git clone --recurse-submodules https://github.com/Materials-Consortia/optimade-python-tools
docker-compose -f ./optimade-python-tools/docker-compose.yml up optimade &
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
- name: Run action
uses: ./
with:
Expand Down Expand Up @@ -154,16 +161,18 @@ jobs:
validator_version:
runs-on: ubuntu-latest
name: Use validator from git commit sha

services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213

steps:
- uses: actions/checkout@v3

- name: Set up and run regular server
run: |
git clone --recurse-submodules https://github.com/Materials-Consortia/optimade-python-tools
docker-compose -f ./optimade-python-tools/docker-compose.yml up optimade &
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
- name: Run action
uses: ./
with:
Expand All @@ -174,16 +183,18 @@ jobs:
validator_version_fail:
runs-on: ubuntu-latest
name: Use validator with wrong version

services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213

steps:
- uses: actions/checkout@v3

- name: Set up and run regular server
run: |
git clone --recurse-submodules https://github.com/Materials-Consortia/optimade-python-tools
docker-compose -f ./optimade-python-tools/docker-compose.yml up optimade &
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
- name: Run action
id: action
continue-on-error: true
Expand All @@ -202,20 +213,22 @@ jobs:
results_output:
runs-on: ubuntu-latest
name: Retrieve and check validator results

services:
optimade:
image: ghcr.io/materials-consortia/optimade:develop
ports:
- 3213:5000
env:
OPTIMADE_BASE_URL: http://gh_actions_host:3213

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.7
uses: actions/setup-python@v3
with:
python-version: 3.7

- name: Set up and run regular server
run: |
git clone --recurse-submodules https://github.com/Materials-Consortia/optimade-python-tools
docker-compose -f ./optimade-python-tools/docker-compose.yml up optimade &
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
python-version: "3.7"

- name: Run action to retrieve output
id: action
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Latest versions:
## Example usage

To run `optimade-validator` for an index meta-database at `http://gh_actions_host:5001/` do the following:
Within the same job, first, start a server, e.g., using the `docker-compose.yml` setup from the [OPTIMADE Python tools repository](https://github.com/Materials-Consortia/optimade-python-tools/blob/master/docker-compose.yml), and then add the step
Within the same job, first, start a server, e.g., using the [`ghcr.io/materials-consortia/optimade` container image](https://github.com/Materials-Consortia/optimade-python-tools/pkgs/container/optimade) as a service, and then add the step

```yml
uses: Materials-Consortia/optimade-validator-action@v2
Expand All @@ -26,6 +26,18 @@ with:
index: yes
```
> **Note**: The service should be used with a set `OPTIMADE_BASE_URL`:
>
> ```yml
> services:
> optimade_index:
> image: ghcr.io/materials-consortia/optimade
> ports:
> - 5001:5000
> env:
> OPTIMADE_BASE_URL: http://gh_actions_host:5001
> ```

To run `optimade-validator` for a regular OPTIMADE _deployed_ implementation, testing all possible versioned base URLs, for example:

- `https://example.org:443/optimade/example/v1`
Expand Down

0 comments on commit 7e620d8

Please sign in to comment.