2021-01-26 12:37:03 +00:00
|
|
|
name: TestNDeploy
|
|
|
|
|
2021-01-28 15:19:30 +00:00
|
|
|
on: [push, pull_request]
|
2021-01-26 12:37:03 +00:00
|
|
|
|
2021-01-23 20:46:54 +00:00
|
|
|
jobs:
|
2021-01-26 12:37:03 +00:00
|
|
|
cache:
|
|
|
|
name: Caching
|
2023-01-06 12:07:20 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-01-26 12:37:03 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-01-06 12:07:20 +00:00
|
|
|
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11" ]
|
2021-01-26 12:37:03 +00:00
|
|
|
|
2021-01-23 20:46:54 +00:00
|
|
|
steps:
|
2022-08-25 19:03:30 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache-dir
|
|
|
|
run: |
|
2022-10-30 11:18:06 +00:00
|
|
|
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: pip cache
|
|
|
|
id: pip-cache
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/cache@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.pip-cache-dir.outputs.dir }}
|
2021-05-13 09:36:56 +00:00
|
|
|
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.py') }}-4
|
2021-04-06 09:02:34 +00:00
|
|
|
- name: Update pip
|
2021-07-26 06:40:39 +00:00
|
|
|
if: ${{ steps.pip-cache.outputs.cache-hit != 'true' }}
|
2021-04-06 09:02:34 +00:00
|
|
|
run: |
|
2021-08-18 08:19:27 +00:00
|
|
|
python -m pip install --upgrade pip
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: Install project dependencies
|
|
|
|
if: ${{ steps.pip-cache.outputs.cache-hit != 'true' }}
|
|
|
|
run: |
|
|
|
|
pip install -r requirements-dev.txt
|
|
|
|
|
|
|
|
lint:
|
|
|
|
name: Linting
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: cache
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-01-06 12:07:20 +00:00
|
|
|
python-version: [3.9]
|
2021-01-26 12:37:03 +00:00
|
|
|
steps:
|
2022-08-25 19:03:30 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
# Retrieve the previously cached dependencies
|
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache
|
|
|
|
run: |
|
2022-10-30 11:18:06 +00:00
|
|
|
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: pip cache
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/cache@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
2021-05-13 09:36:56 +00:00
|
|
|
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.py') }}-4
|
2021-07-26 14:21:17 +00:00
|
|
|
# Update PIP
|
2021-04-06 09:02:34 +00:00
|
|
|
- name: Update pip
|
|
|
|
run: |
|
2021-08-18 08:19:27 +00:00
|
|
|
python -m pip install --upgrade pip
|
2021-01-26 12:37:03 +00:00
|
|
|
# Still need to properly install the dependencies - it will only skip the download part
|
|
|
|
- name: Install project dependencies
|
|
|
|
run: |
|
|
|
|
pip install -r requirements-dev.txt
|
|
|
|
- name: Lint with flake8
|
|
|
|
run:
|
|
|
|
make lint
|
|
|
|
|
|
|
|
test:
|
|
|
|
name: Unit test
|
2023-01-06 12:07:20 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-01-26 12:37:03 +00:00
|
|
|
needs: lint
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2023-01-06 12:07:20 +00:00
|
|
|
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
|
2021-01-26 12:37:03 +00:00
|
|
|
|
|
|
|
steps:
|
2022-08-25 19:03:30 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache
|
|
|
|
run: |
|
2022-10-30 11:18:06 +00:00
|
|
|
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: pip cache
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/cache@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
2021-05-13 09:36:56 +00:00
|
|
|
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.py') }}-4
|
2021-04-06 09:02:34 +00:00
|
|
|
- name: Update pip
|
2021-01-26 12:37:03 +00:00
|
|
|
run: |
|
2021-08-18 08:19:27 +00:00
|
|
|
python -m pip install --upgrade pip
|
2021-04-06 09:02:34 +00:00
|
|
|
- name: Install project dependencies
|
|
|
|
run: |
|
2021-01-26 12:37:03 +00:00
|
|
|
pip install -r requirements-dev.txt
|
|
|
|
pip install pytest-cov
|
2021-07-26 14:21:17 +00:00
|
|
|
pip install pytest-github-actions-annotate-failures
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: Test with pytest
|
|
|
|
run: |
|
2021-10-05 17:11:07 +00:00
|
|
|
make test-only
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: "Upload coverage to Codecov"
|
2021-02-16 17:03:41 +00:00
|
|
|
if: ${{ github.repository == 'spulec/moto'}}
|
2022-10-30 11:18:06 +00:00
|
|
|
uses: codecov/codecov-action@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
2021-05-13 09:36:56 +00:00
|
|
|
fail_ci_if_error: false
|
2021-02-02 18:01:00 +00:00
|
|
|
flags: unittests
|
2021-01-26 12:37:03 +00:00
|
|
|
|
|
|
|
testserver:
|
|
|
|
name: Unit tests in Server Mode
|
2023-01-06 12:07:20 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-01-26 12:37:03 +00:00
|
|
|
needs: lint
|
|
|
|
strategy:
|
2022-09-15 12:27:07 +00:00
|
|
|
fail-fast: false
|
2021-01-26 12:37:03 +00:00
|
|
|
matrix:
|
2023-01-06 12:07:20 +00:00
|
|
|
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
|
2021-01-26 12:37:03 +00:00
|
|
|
|
|
|
|
steps:
|
2022-08-25 19:03:30 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-02-12 12:59:45 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Start MotoServer
|
|
|
|
run: |
|
|
|
|
python setup.py sdist
|
2021-11-29 20:35:18 +00:00
|
|
|
docker run --rm -t --name motoserver -e TEST_SERVER_MODE=true -e AWS_SECRET_ACCESS_KEY=server_secret -e AWS_ACCESS_KEY_ID=server_key -v `pwd`:/moto -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock python:3.7-buster /moto/scripts/ci_moto_server.sh &
|
|
|
|
python scripts/ci_wait_for_server.py
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache
|
|
|
|
run: |
|
2022-10-30 11:18:06 +00:00
|
|
|
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
2021-01-26 12:37:03 +00:00
|
|
|
- name: pip cache
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/cache@v3
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
2021-05-13 09:36:56 +00:00
|
|
|
key: pip-${{ matrix.python-version }}-${{ hashFiles('**/setup.py') }}-4
|
2021-04-06 09:02:34 +00:00
|
|
|
- name: Update pip
|
2021-01-26 12:37:03 +00:00
|
|
|
run: |
|
2021-08-18 08:19:27 +00:00
|
|
|
python -m pip install --upgrade pip
|
2021-04-06 09:02:34 +00:00
|
|
|
- name: Install project dependencies
|
|
|
|
run: |
|
2021-01-26 12:37:03 +00:00
|
|
|
pip install -r requirements-dev.txt
|
2021-02-02 18:01:00 +00:00
|
|
|
- name: Test ServerMode/Coverage
|
|
|
|
env:
|
|
|
|
TEST_SERVER_MODE: ${{ true }}
|
|
|
|
run: |
|
2021-10-05 17:11:07 +00:00
|
|
|
make test-only
|
2021-02-02 18:01:00 +00:00
|
|
|
- name: "Upload coverage to Codecov"
|
2021-02-16 17:03:41 +00:00
|
|
|
if: ${{ github.repository == 'spulec/moto'}}
|
2022-10-30 11:18:06 +00:00
|
|
|
uses: codecov/codecov-action@v3
|
2021-02-02 18:01:00 +00:00
|
|
|
with:
|
2021-05-13 09:36:56 +00:00
|
|
|
fail_ci_if_error: false
|
2021-02-02 18:01:00 +00:00
|
|
|
flags: servertests
|
2021-10-05 17:11:07 +00:00
|
|
|
- name: "Stop MotoServer"
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
mkdir serverlogs
|
|
|
|
pwd
|
|
|
|
ls -la
|
|
|
|
cp server_output.log serverlogs/server_output.log
|
|
|
|
docker stop motoserver
|
|
|
|
- name: Archive TF logs
|
|
|
|
if: always()
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-10-05 17:11:07 +00:00
|
|
|
with:
|
|
|
|
name: motoserver-${{ matrix.python-version }}
|
|
|
|
path: |
|
|
|
|
serverlogs/*
|
2021-01-26 12:37:03 +00:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
name: Deploy
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-16 10:02:57 +00:00
|
|
|
needs: [test, testserver ]
|
2021-01-28 15:19:30 +00:00
|
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'spulec/moto' }}
|
2021-01-26 12:37:03 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
python-version: [3.8]
|
|
|
|
steps:
|
2022-08-25 19:03:30 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-03-03 09:57:08 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-03-03 09:57:08 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2021-03-05 12:36:32 +00:00
|
|
|
- name: Update & Build
|
2021-01-26 12:37:03 +00:00
|
|
|
run: |
|
2021-03-05 12:36:32 +00:00
|
|
|
pip install wheel packaging
|
2021-01-26 12:37:03 +00:00
|
|
|
python update_version_from_git.py
|
|
|
|
python setup.py sdist bdist_wheel
|
|
|
|
- name: Publish to PyPI
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
2021-01-26 12:37:03 +00:00
|
|
|
with:
|
|
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
2021-08-28 10:05:19 +00:00
|
|
|
- name: Build Docker release
|
2021-08-28 10:23:02 +00:00
|
|
|
run: |
|
|
|
|
docker build -t motoserver/moto . --tag moto:latest
|
2022-02-18 11:54:58 +00:00
|
|
|
# Required to get the correct Digest
|
|
|
|
# See https://github.com/docker/build-push-action/issues/461
|
|
|
|
- name: Set up Docker Buildx
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2021-08-28 10:05:19 +00:00
|
|
|
- name: Login to DockerHub
|
2022-08-25 19:03:30 +00:00
|
|
|
uses: docker/login-action@v2
|
2021-08-28 10:05:19 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
tags: motoserver/moto:latest
|
2021-03-20 16:36:00 +00:00
|
|
|
- name: Get version number
|
|
|
|
run: |
|
|
|
|
version=$(grep -oP '(?<=__version__ = ")[0-9.a-z]+(?=")' moto/__init__.py)
|
|
|
|
echo "moto_version=$version" >> $GITHUB_ENV
|
2021-03-21 10:18:53 +00:00
|
|
|
- uses: octokit/graphql-action@v2.x
|
|
|
|
name: Get PR info
|
|
|
|
id: get_pr
|
|
|
|
with:
|
|
|
|
query: |
|
|
|
|
query get_pr($owner:String!,$repo:String!,$commit:GitObjectID) {
|
|
|
|
repository(owner:$owner,name:$repo) {
|
|
|
|
object(oid:$commit) {
|
|
|
|
... on Commit {
|
|
|
|
associatedPullRequests(last: 1){
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
baseRepository {
|
|
|
|
nameWithOwner
|
|
|
|
}
|
|
|
|
merged
|
|
|
|
number
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
owner: ${{ github.event.repository.owner.name }}
|
|
|
|
repo: ${{ github.event.repository.name }}
|
|
|
|
commit: "${{ github.sha }}"
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2021-03-20 16:36:00 +00:00
|
|
|
- name: Get PR number
|
|
|
|
run: |
|
2021-03-21 10:18:53 +00:00
|
|
|
nr="${{ fromJSON(steps.get_pr.outputs.data).repository.object.associatedPullRequests.edges[0].node.number }}"
|
|
|
|
repo="${{ fromJSON(steps.get_pr.outputs.data).repository.object.associatedPullRequests.edges[0].node.baseRepository.nameWithOwner }}"
|
2021-03-20 16:36:00 +00:00
|
|
|
if [ -z "$nr" ]
|
|
|
|
then
|
|
|
|
echo "PR nr not found in $msg"
|
|
|
|
echo "pr_found=false" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "PR NR: $nr"
|
|
|
|
echo "pr_nr=$nr" >> $GITHUB_ENV
|
2021-03-21 10:18:53 +00:00
|
|
|
echo "pr_repo=$repo" >> $GITHUB_ENV
|
2021-03-20 16:36:00 +00:00
|
|
|
echo "pr_found=true" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
- name: Leave PR comment with Moto version
|
|
|
|
uses: peter-evans/create-or-update-comment@v1
|
2021-03-21 10:18:53 +00:00
|
|
|
if: env.pr_found == 'true' && env.pr_repo == 'spulec/moto'
|
2021-03-20 16:36:00 +00:00
|
|
|
with:
|
|
|
|
issue-number: ${{ env.pr_nr }}
|
|
|
|
body: |
|
|
|
|
This is now part of moto >= ${{ env.moto_version }}
|