diff --git a/start/requirements.txt b/.github/workflows/requirements.in similarity index 100% rename from start/requirements.txt rename to .github/workflows/requirements.in diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt new file mode 100644 index 0000000..66c7242 --- /dev/null +++ b/.github/workflows/requirements.txt @@ -0,0 +1,62 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in --python-version 3.9 --python-platform linux --no-build +certifi==2024.6.2 + # via requests +cffi==1.16.0 + # via cryptography +charset-normalizer==3.3.2 + # via requests +cryptography==42.0.8 + # via openstacksdk +decorator==5.1.1 + # via + # dogpile-cache + # openstacksdk +dogpile-cache==1.3.3 + # via openstacksdk +idna==3.7 + # via requests +iso8601==2.1.0 + # via + # keystoneauth1 + # openstacksdk +jmespath==1.0.1 + # via openstacksdk +jsonpatch==1.33 + # via openstacksdk +jsonpointer==2.4 + # via jsonpatch +keystoneauth1==5.6.0 + # via openstacksdk +netifaces==0.11.0 + # via openstacksdk +openstacksdk==3.1.0 + # via -r requirements.in +os-service-types==1.7.0 + # via + # keystoneauth1 + # openstacksdk +pbr==6.0.0 + # via + # keystoneauth1 + # openstacksdk + # os-service-types + # stevedore +platformdirs==4.2.2 + # via openstacksdk +pycparser==2.22 + # via cffi +pyyaml==6.0.1 + # via openstacksdk +requests==2.32.3 + # via keystoneauth1 +requestsexceptions==1.4.0 + # via openstacksdk +stevedore==5.2.0 + # via + # dogpile-cache + # keystoneauth1 +typing-extensions==4.12.1 + # via dogpile-cache +urllib3==2.2.1 + # via requests diff --git a/.github/workflows/start.yaml b/.github/workflows/start.yaml new file mode 100644 index 0000000..d31caec --- /dev/null +++ b/.github/workflows/start.yaml @@ -0,0 +1,57 @@ +name: Start + +on: + workflow_call: + inputs: + number: + description: 'Number of runners to start.' + required: false + default: -1 + type: number + + secrets: + OS_APPLICATION_CREDENTIAL_ID: + required: true + OS_APPLICATION_CREDENTIAL_SECRET: + required: true + + outputs: + exit_code: + description: "The exit code from start.py" + value: ${{ jobs.action_runners.outputs.exit_code }} + +jobs: + action_runners: + name: action runners + runs-on: ubuntu-latest + outputs: + exit_code: ${{ steps.start.outputs.exit_code }} + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + repository: glotzerlab/jetstream2-admin + ref: ${{ github.workflow_sha }} + # Python 3.9 is the latest possible because netifaces has no new releases + - name: Set up Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: "3.9" + - name: Install openstack + uses: glotzerlab/workflows/setup-uv@5cfac9da9cb78e16ae97a9119b6fd13c1c2d6f5e # 0.1.0 + with: + lockfile: ".github/workflows/requirements.txt" + - id: start + name: Start action runners + continue-on-error: true + run: | + python3 start/start-action-runners.py ${{ inputs.number }} + echo "exit_code=$?" >> $GITHUB_OUTPUT + env: + OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} + OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} + OS_AUTH_TYPE: v3applicationcredential + OS_AUTH_URL: https://js2.jetstream-cloud.org:5000/v3/ + OS_IDENTITY_API_VERSION: 3 + OS_REGION_NAME: "IU" + OS_INTERFACE: public diff --git a/.github/workflows/start.yml b/.github/workflows/start.yml deleted file mode 100644 index a92c2e1..0000000 --- a/.github/workflows/start.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Start action runners - -on: - pull_request: - - workflow_dispatch: - -jobs: - start: - name: Test start composite action - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4.1.6 - - name: Start action runners - uses: ./start - with: - OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} - OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..26fe781 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,19 @@ +name: Test + +on: + pull_request: + + workflow_dispatch: + +jobs: + start_workflow: + name: Test start workflow + uses: ./.github/workflows/start.yaml + secrets: inherit + + check_output: + needs: start_workflow + runs-on: ubuntu-latest + + steps: + - run: "echo Exit code: ${{ needs.start_workflow.outputs.exit_code }}" diff --git a/start/action.yml b/start/action.yml deleted file mode 100644 index 365eec9..0000000 --- a/start/action.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Start action runners -description: Start action runners - -inputs: - OS_APPLICATION_CREDENTIAL_ID: - required: true - OS_APPLICATION_CREDENTIAL_SECRET: - required: true - number: - description: 'Number of runners to start.' - required: false - default: -1 - -runs: - using: "composite" - steps: - - uses: actions/cache@v4.0.2 - with: - path: ~/.cache/pip - key: jetstream2-admin-${{ runner.os }}-pip-v1.2.2-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - jetstream2-admin-${{ runner.os }}-pip- - - name: Install openstack - run: python3 -m pip install -r ${{ github.action_path }}/requirements.txt - shell: bash - - name: Start action runners - run: python3 ${{ github.action_path }}/start-action-runners.py ${{ inputs.number }} - shell: bash - env: - OS_APPLICATION_CREDENTIAL_ID: ${{ inputs.OS_APPLICATION_CREDENTIAL_ID }} - OS_APPLICATION_CREDENTIAL_SECRET: ${{ inputs.OS_APPLICATION_CREDENTIAL_SECRET }} - OS_AUTH_TYPE: v3applicationcredential - OS_AUTH_URL: https://js2.jetstream-cloud.org:5000/v3/ - OS_IDENTITY_API_VERSION: 3 - OS_REGION_NAME: "IU" - OS_INTERFACE: public diff --git a/start/start-action-runners.py b/start/start-action-runners.py index a4f9a8a..0b6c5d7 100644 --- a/start/start-action-runners.py +++ b/start/start-action-runners.py @@ -67,7 +67,7 @@ def bring_runners_online(connection, N): sys.stdout.flush() - return total_runners == active_runners + return (total_runners == active_runners, active_runners) if __name__ == '__main__': @@ -87,13 +87,20 @@ def bring_runners_online(connection, N): connection = openstack.connect() except Exception as e: print('::warning:: Failed to connect to cloud:', str(e)) - sys.exit(0) + sys.exit(1) # attempt to bring the servers online several times before returning attempts = 0 - while (not bring_runners_online(connection, args.N) - and attempts < NUM_ATTEMPTS): + done, active_runners = bring_runners_online(connection, args.N) + while (not done and attempts < NUM_ATTEMPTS): attempts += 1 print(f'Waiting {TIME_BETWEEN_ATTEMPTS} seconds...', flush=True) time.sleep(TIME_BETWEEN_ATTEMPTS) print('', flush=True) + done, active_runners = bring_runners_online(connection, args.N) + + if active_runners == 0: + sys.exit(2) + + # testing + sys.exit(3)