Skip to content

Commit

Permalink
pants ci: add ST2_CI var to enable ci-only tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Nov 7, 2024
1 parent 5462197 commit 7077ee3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
65 changes: 41 additions & 24 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ jobs:
env:
COLUMNS: '120'

# Tell StackStorm that we are indeed in CI mode, using our CI-provider agnostic var.
ST2_CI: 'true'

# GitHub Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -99,11 +107,6 @@ jobs:
gha-cache-key: cache0-py${{ matrix.python.version }}

- name: Test pants-plugins
env:
# Github Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'
run: |
pants test pants-plugins/::
Expand Down Expand Up @@ -164,6 +167,14 @@ jobs:
env:
COLUMNS: '120'

# Tell StackStorm that we are indeed in CI mode, using our CI-provider agnostic var.
ST2_CI: 'true'

# GitHub Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -197,11 +208,6 @@ jobs:
gha-cache-key: cache0-py${{ matrix.python.version }}

- name: Unit Tests
env:
# Github Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'
run: >
pants
--python-bootstrap-search-path=[]
Expand Down Expand Up @@ -260,6 +266,14 @@ jobs:
env:
COLUMNS: '120'

# Tell StackStorm that we are indeed in CI mode, using our CI-provider agnostic var.
ST2_CI: 'true'

# GitHub Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -293,11 +307,6 @@ jobs:
gha-cache-key: cache0-py${{ matrix.python.version }}

- name: Pack Tests
env:
# Github Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'
run: >
pants
--python-bootstrap-search-path=[]
Expand Down Expand Up @@ -355,6 +364,14 @@ jobs:
env:
COLUMNS: '120'

# Tell StackStorm that we are indeed in CI mode, using our CI-provider agnostic var.
ST2_CI: 'true'

# GitHub Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -451,6 +468,15 @@ jobs:
env:
COLUMNS: '120'

# Tell StackStorm that we are indeed in CI mode, using our CI-provider agnostic var.
ST2_CI: 'true'
ST2_CI_RUN_ORQUESTA_PAUSE_RESUME_TESTS: 'true'

# GitHub Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -494,19 +520,10 @@ jobs:
- name: Launch Dev ST2 Cluster
env:
VIRTUALENV_DIR: ./dist/export/python/virtualenvs/st2/${{ steps.python.outputs.python-version }}
# Github Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'
run: |
sudo -E ./scripts/github/prepare-integration.sh
- name: Integration Tests
env:
# Github Actions uses the 'runner' user, so use that instead of stanley.
ST2TESTS_SYSTEM_USER: 'runner'
ST2TESTS_REDIS_HOST: '127.0.0.1'
ST2TESTS_REDIS_PORT: '6379'
run: >
pants
--python-bootstrap-search-path=[]
Expand Down
3 changes: 3 additions & 0 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ extra_env_vars = [
# Use these to override the redis host and port
"ST2TESTS_REDIS_HOST",
"ST2TESTS_REDIS_PORT",
# CI-specific vars
"ST2_CI",
"ST2_CI_RUN_ORQUESTA_PAUSE_RESUME_TESTS",
]

[twine]
Expand Down
6 changes: 4 additions & 2 deletions scripts/github/prepare-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ source "${VIRTUALENV_DIR}/bin/activate"

# Enable coordination backend to avoid race conditions with orquesta tests due
# to the lack of the coordination backend
sed -i "s#\#url = redis://localhost#url = redis://127.0.0.1#g" ./conf/st2.dev.conf
sed -i "s#\#url = redis://localhost#url = redis://127.0.0.1#g" ./conf/st2.ci.conf || true
if [ -z "${ST2TESTS_REDIS_HOST}" ] || [ -z "${ST2TESTS_REDIS_PORT}"]; then
sed -i "s#\#url = redis://localhost#url = redis://127.0.0.1#g" ./conf/st2.dev.conf
sed -i "s#\#url = redis://localhost#url = redis://127.0.0.1#g" ./conf/st2.ci.conf || true
fi

echo "Used config for the tests"
echo ""
Expand Down

0 comments on commit 7077ee3

Please sign in to comment.