From 7e620d85feab901da629f4e07eccbac98ba8b652 Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com> Date: Mon, 16 May 2022 17:59:46 +0200 Subject: [PATCH] Use the `optimade` container image as a service (#107) 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`. --- .github/workflows/ci_tests.yml | 99 +++++++++++++++++++--------------- README.md | 14 ++++- 2 files changed, 69 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 426640d..0ace257 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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 @@ -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 diff --git a/README.md b/README.md index d1f0ce3..cb1773f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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`