Skip to content

Use the newly created bats image on ghcr.io #171

Use the newly created bats image on ghcr.io

Use the newly created bats image on ghcr.io #171

Workflow file for this run

name: Test optimade-validator GitHub Action
on:
pull_request:
push:
branches:
- master
- 'push-action/**'
env:
PYTHON_VERSION: 3.9
jobs:
pre-commit:
runs-on: ubuntu-latest
name: Pre-commit
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
while IFS="" read -r line || [ -n "${line}" ]; do
if [[ "${line}" =~ ^pre-commit.*$ ]]; then
pre_commit="${line}"
fi
done < requirements.txt
pip install ${pre_commit}
- name: Run pre-commit
run: SKIP=pylint pre-commit run --all-files --show-diff-on-failure
pylint-safety:
runs-on: ubuntu-latest
name: PyLint & Safety
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -r requirements.txt
pip install safety
- name: Run pylint
run: pylint --rcfile=pyproject.toml *.py
# ID: 70612
# Package: Jinja2
# Has been disputed by the maintainer and multiple third parties.
# For more information see: https://github.com/advisories/GHSA-f6pv-j8mr-w6rr
- name: Run safety
run: pip freeze | safety check --stdin --ignore=70612
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@v4
- name: Run action (validating the unversioned path)
uses: ./
with:
port: 3213
path: /
validate unversioned path: yes
- name: Run action (without validating the unversioned path)
uses: ./
with:
port: 3213
path: /
validate unversioned path: no
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@v4
- name: Run action
uses: ./
with:
port: 3214
path: /
index: yes
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@v4
- name: Run action
uses: ./
with:
port: 3213
path: /
all versioned paths: yes
validate unversioned path: yes
- name: Run action (setting path to empty string)
uses: ./
with:
port: 3213
path: ""
all versioned paths: yes
validate unversioned path: yes
bats:
runs-on: ubuntu-latest
name: Run BATS test suite for entrypoint.sh
permissions:
packages: read
env:
# Latest BATS version
# If a new BATS version is released, a new Docker image should be built
# and uploaded to ghcr.io/materials-consortia/bats with the new version tag
# as well as an approprate alpine version (using the `bashver` build arg).
BATS_VERSION: '1.11.0'
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghrc.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build BATS environment
uses: docker/build-push-action@v5
with:
context: ./tests
push: false
load: true
tags: optimade_bats
- name: Run BATS tests
run: ./run_tests.sh
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@v4
- name: Run action
uses: ./
with:
port: 3213
path: /
validator version: c6551e27f64abdaa94afd401db22af9ef2afd23d
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@v4
- name: Run action
id: action
continue-on-error: true
uses: ./
with:
port: 3213
path: /
validator version: "0.0.0"
- name: This runs ONLY if 'Run action' doesn't fail as expected
if: steps.action.outcome != 'failure' || steps.action.conclusion != 'success'
run: |
echo "Outcome: ${{ steps.action.outcome }} (not 'failure'), Conclusion: ${{ steps.action.conclusion }} (not 'success')"
exit 1
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@v4
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Run action to retrieve output
id: action
uses: ./
with:
port: 3213
path: /
create output: true
- name: Check "default" output
env:
RESULTS: "${{ steps.action.outputs.results }}"
run: python .github/utils/ci_helper.py default
- name: Run action with "all versioned paths" to retrieve output
id: action_all
uses: ./
with:
port: 3213
path: /
create output: true
all versioned paths: true
- name: Check "all versioned paths" output
env:
RESULTS: "${{ steps.action_all.outputs.results }}"
run: python .github/utils/ci_helper.py all_versioned_paths
- name: Run action with "validate unversioned path" to retrieve output
id: action_unversioned
uses: ./
with:
port: 3213
path: /
create output: true
validate unversioned path: true
- name: Check "validate unversioned path" output
env:
RESULTS: "${{ steps.action_unversioned.outputs.results }}"
run: python .github/utils/ci_helper.py validate_unversioned_path
- name: Run action with "as type" to retrieve output
id: action_astype
uses: ./
with:
port: 3213
path: /v1.1/structures
create output: true
as type: structures
- name: Check "as type" output
env:
RESULTS: "${{ steps.action_astype.outputs.results }}"
run: python .github/utils/ci_helper.py as_type