Skip to content

SOAR

SOAR #10946

Workflow file for this run

name: Model Logic
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 120
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: skyportal
POSTGRES_PASSWORD: anything
ports:
- 5432:5432
# needed because the postgres container does not provide a
# healthcheck
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Checkout main
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
submodules: true
- uses: actions/cache@v2
with:
path: |
~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }}
- uses: actions/cache@v2
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
- name: Write SkyPortal configs
run: |
cat << EOF > config.yaml
database:
database: skyportal
host: localhost
port: 5432
user: skyportal
password: anything
EOF
cat << EOF > test_config.yaml
database:
database: skyportal_test
user: skyportal
host: localhost
port: 5432
password: anything
server:
auth:
debug_login: True
EOF
- name: Install system dependencies
run: |
sudo apt update -y
### firefox installation
sudo snap remove firefox
sudo add-apt-repository ppa:mozillateam/ppa
printf 'Package: *\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 1001' | sudo tee /etc/apt/preferences.d/mozilla-firefox
sudo apt install -y wget unzip firefox nginx libcurl4-gnutls-dev libgnutls28-dev
pip install pip==23.1.2
pip install wheel numpy
export NPM_PACKAGES="${HOME}/.npm-packages"
export PATH=${NPM_PACKAGES}/bin:$PATH
export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
sudo npm -g install npm@latest
which python; python --version
echo npm $(npm --version)
echo node $(node --version)
nginx -v
firefox --version
- name: Checkout branch being tested
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
clean: false
- name: Initialize SkyPortal
run: |
# Usually, we create databases on the local machine, so
# `createdb` just works out of the box. However, when doing
# this on a server, as in our case, we need to specify extra
# options.
#
# db_init should not complain if the databases exist already
#
echo "localhost:5432:*:skyportal:anything" > ~/.pgpass
chmod 600 ~/.pgpass
createdb -h localhost -U skyportal skyportal_test
psql -U skyportal -h localhost -c "GRANT ALL PRIVILEGES ON DATABASE skyportal_test TO skyportal;" skyportal_test
export NPM_CONFIG_LEGACY_PEER_DEPS="true"
make db_init
pip list --format=columns
npm ls --depth 0 || true
- name: Install Geckodriver / Selenium
run: |
GECKO_VER=0.34.0
CACHED_DOWNLOAD_DIR=~/.local/downloads
FILENAME=geckodriver-v${GECKO_VER}-linux64.tar.gz
if [[ ! -f ${CACHED_DOWNLOAD_DIR=}/${FILENAME} ]]; then
wget https://github.com/mozilla/geckodriver/releases/download/v${GECKO_VER}/${FILENAME} --directory-prefix=${CACHED_DOWNLOAD_DIR} --no-clobber
fi
sudo tar -xzf ${CACHED_DOWNLOAD_DIR}/geckodriver-v${GECKO_VER}-linux64.tar.gz -C /usr/local/bin
geckodriver --version
python -c "import selenium; print(f'Selenium {selenium.__version__}')"
- name: Refresh SkyPortal dependencies for tested version
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)
export NPM_CONFIG_LEGACY_PEER_DEPS="true"
make dependencies
- name: Formatting and linting checks
if: github.ref != 'refs/heads/main'
run: |
pip install pre-commit
pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
- name: Test loading demo data
run: |
make run &
sleep 180 && make load_demo_data
kill %1
- name: Run test suite
run: |
PYTHONPATH=. python baselayer/tools/test_frontend.py --xml --headless 'skyportal/tests/models'
- name: Upload logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs
path: log
- name: Upload test post-mortem reports
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: test-results
path: test-results