-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from internap/test-build-push-github
build and publish using github actions
- Loading branch information
Showing
4 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Pulls | ||
on: pull_request | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['2.7'] | ||
tox_env: ['py27'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install tox | ||
tox -e ${{ matrix.tox_env }} --notest | ||
- name: Run | ||
run: | | ||
tox -e ${{ matrix.tox_env }} -- --nocapture | ||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [ '2.7' ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install tox | ||
tox -r -e pep8 --notest | ||
- name: lint | ||
run: | | ||
tox -e pep8 | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['2.7'] | ||
tox_env: ['py27'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: docker build | ||
run: | | ||
docker build . -t internap/netman:latest | ||
- name: docker verify | ||
run: | | ||
docker compose up -d | ||
docker inspect -f {{.State.Running}} netman-tsr1.yul1.example.net-1 | ||
docker inspect -f {{.State.Running}} netman-netman-1 | ||
while [[ $(docker inspect -f {{.State.Health.Status}} netman-netman-1) != "healthy" ]]; do echo "Container is" $(docker inspect -f {{.State.Health.Status}} netman-netman-1); sleep 1; done; | ||
curl --fail -vvv -X POST http://localhost:32771/switches/netman-tsr1.yul1.example.net-1/vlans -d '{"number": 1000, "name": "myvlan"}' -H 'Content-Type: application/json' -H 'Netman-model: cisco' -H 'Netman-username: root' -H 'Netman-password: root' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
--- | ||
|
||
name: release | ||
|
||
on: | ||
release: | ||
types: [released, prereleased] | ||
|
||
jobs: | ||
build-and-publish-pypi: | ||
permissions: | ||
contents: read | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python_version: ["2.7"] | ||
tox_env: ['py27'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: "Set up Python ${{ matrix.python_version }}" | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
- name: Install dependencies | ||
run: python -m pip install --upgrade pip | ||
- name: Install building dependencies | ||
run: pip install wheel tox | ||
- name: Build venv | ||
run: | | ||
tox -e ${{ matrix.tox_env }} --notest | ||
- name: Run | ||
run: | | ||
rm -rf dist || true | ||
.tox/${{ matrix.tox_env }}/bin/python setup.py sdist bdist_wheel | ||
- name: Publish a Python distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.event_name == 'release' | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
docker-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: internap/netman | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build and push Docker image | ||
if: github.event_name == 'release' | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters