Skip to content

Modernize action CI and update deps #709

Modernize action CI and update deps

Modernize action CI and update deps #709

Workflow file for this run

name: "CI"
on:
pull_request:
branches:
- main
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: open-turo/actions-gha/lint@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fast:
name: Test / Fast
runs-on: ubuntu-latest
steps:
- uses: open-turo/actions-gha/test@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
TEST_FAST: "1"
NO_TEST_JAVA: "1"
# Runs unit tests
test:
name: Test
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: open-turo/actions-gha/test@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NO_TEST_JAVA: "1"
# Build and run the action from this repo to test full functionality
action:
name: Test / Inputs
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/action-test
with:
use-versions: false
env:
IGNORE_INSTALLED: "true"
# Build and run the action from this repo to test full functionality
action-versions:
name: Test / Version files
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/action-test
with:
use-versions: true
env:
IGNORE_INSTALLED: "true"
action-asdf:
name: Test / Pre-installed
needs: [lint, fast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
# Create .tool-versions for asdf
{
echo "golang 1.17.6"
echo "java temurin-17.0.2+8"
echo "nodejs 16.13.2"
echo "python 3.10.2"
echo "terraform 1.1.5"
} > .tool-versions
- uses: asdf-vm/actions/install@v2
- run: |
# Test versions
go version | grep "1.17.6"
java -version 2>&1 | grep "17.0.2"
node --version | grep "16.13.2"
python --version || grep "3.10.2"
terraform --version | grep "1.1.5"
- uses: ./.github/actions/action-test
env:
TEST_PRE_INSTALL: "true"
- run: |
# Test versions again
go version | grep "1.17.6"
java -version 2>&1 | grep "17.0.2"
node --version | grep "16.13.2"
python --version || grep "3.10.2"
terraform --version | grep "1.1.5"
# Build and run the action from this repo to test full functionality
action-python-system:
name: Test / Regresstion / System python
# needs: [lint] # TODO: Reinstate this after done with fast testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Debug system python
# if: "false" # Comment this out for add'l debug
run: |
echo "::debug:: $(python --version)"
- name: Set python version
run: echo "3.10.4" > .python-version
- uses: ./
- name: Debug configured python
# if: "false" # Comment this out for add'l debug
run: |
echo "::debug::python --version; $(python --version || true)"
echo "::debug::pip --version: $(pip --version || true)"
- run: |
# Test versions
python --version || exit 10
pip --version || exit 11
# Build and run the action from this repo to test full functionality
action-regression:
name: Test / Regression / pyenv
# needs: [lint] # TODO: Reinstate this after done with fast testing
runs-on: ubuntu-latest
env:
DESIRED_PYTHON_VERSION: 3.9.13
UPGRADE_PYTHON_VERSION: 3.10.6
steps:
- uses: actions/checkout@v4
- name: Install pyenv on hosted runner
run: |
# Installing pyenv
echo "::debug::Installing pyenv"
curl https://pyenv.run | bash
echo "::debug::Exporting environment"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
echo "::debug::Intializing pyenv"
eval "$(pyenv init -)"
echo "::debug::Installing python $UPGRADE_PYTHON_VERSION"
pyenv install "$UPGRADE_PYTHON_VERSION"
echo "::debug::Rehashing shims"
pyenv rehash
- name: Debug env
if: "false" # Comment this out for add'l debug
run: env | sort
- name: Create version files
run: echo "${DESIRED_PYTHON_VERSION}" > .python-version
- name: Setup python
uses: actions/setup-python@v5
- name: Debug environment
if: "false" # Comment this out for add'l debug
run: |
export PYENV_ROOT="$HOME/.pyenv"
echo "::debug::python --version: $(python --version 2>&1 || true)"
echo "::debug::python3 --version: $(python3 --version 2>&1 || true)"
echo "::debug::pyenv should not be on the path:"
echo "::debug::which pyenv:$(which pyenv 2>&1 || true)"
echo "::debug::We manually supply the path:"
echo "::debug::pyenv versions: $("$PYENV_ROOT/bin/pyenv" versions 2>&1 || true)"
echo "::debug::~/.pyenv/shims: $(ls -1 "$("$PYENV_ROOT/bin/pyenv" root)/shims" 2>&1 || true)"
echo -e "::debug::PATH:\n$(echo "$PATH" | tr ":" "\n")"
- name: Run action-setup-tools
uses: ./
- name: Pyenv should not preempt actions/setup-python if SemVer is ok
shell: bash
run: |
# Check versions
output="$(python --version 2>&1 || true)"
echo "::debug::python --version: $output"
echo "::debug::python3 --version: $(python3 --version 2>&1 || true)"
echo "::debug::pyenv versions: $(pyenv versions 2>&1 || true)"
echo "::debug::.pyenv/shims: $(ls -1 "$HOME/.pyenv/shims" 2>&1 || true)"
echo -e "::debug::PATH:\n$(echo "$PATH" | tr ":" "\n")"
echo "$output" | grep -i "pyenv: version .* not installed" && \
{
echo "::error:: Expected python --version to work, hit pyenv instead."
echo "::debug::$(pyenv versions)"
echo "::debug::$(echo "$PATH" | tr ":" "\n")"
exit 1
}
version=$(echo "$output" | awk '{print $2}')
echo "::debug::Found version: $version"
echo "::debug::Desired version: $DESIRED_PYTHON_VERSION"
if [[ "$version" != "$DESIRED_PYTHON_VERSION" ]]; then
echo "::error::Expected python --version to return '$DESIRED_PYTHON_VERSION', got '$version'"
exit 1
fi
echo "Success!"
- name: Create upgraded version files
run: echo "$UPGRADE_PYTHON_VERSION" > .python-version
- name: Run action-setup-tools
uses: ./
- name: Pyenv upgrades if SemVer is NOT satisfied
shell: bash
run: |
# Check versions
output="$(python --version 2>&1 || true)"
echo "::debug::python --version: $output"
echo "::debug::python3 --version: $(python3 --version 2>&1 || true)"
echo "::debug::pyenv versions: $(pyenv versions 2>&1 || true)"
echo "::debug::.pyenv/shims: $(ls -1 "$HOME/.pyenv/shims" 2>&1 || true)"
echo -e "::debug::PATH:\n$(echo "$PATH" | tr ":" "\n")"
echo "$output" | grep -i "pyenv: version .* not installed" && \
{
echo "::error:: Expected python --version to work, hit pyenv instead."
echo "::debug::$(pyenv versions)"
echo "::debug::$(echo "$PATH" | tr ":" "\n")"
exit 1
}
version=$(echo "$output" | awk '{print $2}')
echo "::debug::Found version: $version"
echo "::debug::Desired version: $UPGRADE_PYTHON_VERSION"
if [[ "$version" != "$UPGRADE_PYTHON_VERSION" ]]; then
echo "::error::Expected python --version to return '$UPGRADE_PYTHON_VERSION', got '$version'"
exit 1
fi
echo "Success!"