|
| 1 | +name: CI-CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - release/messaging-v3 |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + python-version: ["3.10"] |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: set up python ${{ matrix.python-version }} |
| 17 | + uses: actions/setup-python@v2 |
| 18 | + with: |
| 19 | + python-version: ${{ matrix.python-version }} |
| 20 | + - name: install poetry |
| 21 | + run: | |
| 22 | + python -m pip install --upgrade pip |
| 23 | + pip install poetry |
| 24 | + |
| 25 | + id: cache-poetry |
| 26 | + with: |
| 27 | + path: ~/.virtualenvs |
| 28 | + key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock', 'poetry.toml') }} |
| 29 | + - name: Configure poetry for ci |
| 30 | + run: | |
| 31 | + poetry config virtualenvs.in-project false --local |
| 32 | + poetry config virtualenvs.path ~/.virtualenvs --local |
| 33 | + - name: Install dependencies |
| 34 | + if: steps.cache-poetry.outputs.cache-hit != 'true' |
| 35 | + run: | |
| 36 | + poetry update && poetry install --no-root |
| 37 | + - name: run tests |
| 38 | + env: |
| 39 | + VALID_TELSTRA_CLIENT_ID: ${{ secrets.VALID_TELSTRA_CLIENT_ID }} |
| 40 | + VALID_TELSTRA_CLIENT_SECRET: ${{ secrets.VALID_TELSTRA_CLIENT_SECRET }} |
| 41 | + run: | |
| 42 | + poetry run pytest || (poetry install --no-root && poetry run pytest) |
| 43 | +
|
| 44 | + pre-commit: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v2 |
| 48 | + - name: Set up Python |
| 49 | + uses: actions/setup-python@v2 |
| 50 | + with: |
| 51 | + python-version: "3.10" |
| 52 | + - uses: pre-commit/[email protected] |
| 53 | + |
| 54 | + build: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v2 |
| 58 | + - name: Set up Python |
| 59 | + uses: actions/setup-python@v2 |
| 60 | + with: |
| 61 | + python-version: "3.10" |
| 62 | + - name: Install poetry |
| 63 | + run: pip install poetry |
| 64 | + |
| 65 | + id: cache-poetry |
| 66 | + with: |
| 67 | + path: ~/.virtualenvs |
| 68 | + key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock', 'poetry.toml') }} |
| 69 | + - name: Configure poetry for ci |
| 70 | + run: | |
| 71 | + poetry config virtualenvs.in-project false --local |
| 72 | + poetry config virtualenvs.path ~/.virtualenvs --local |
| 73 | + - name: Update lock file |
| 74 | + run: | |
| 75 | + poetry lock |
| 76 | + - name: Install dependencies |
| 77 | + if: steps.cache-poetry.outputs.cache-hit != 'true' |
| 78 | + run: | |
| 79 | + poetry install |
| 80 | + - name: Build packages |
| 81 | + run: poetry build |
| 82 | + - name: Upload artifacts for release |
| 83 | + |
| 84 | + with: |
| 85 | + name: wheel |
| 86 | + path: dist/ |
| 87 | + |
| 88 | + release-required: |
| 89 | + runs-on: ubuntu-latest |
| 90 | + outputs: |
| 91 | + result: ${{ steps.check.outputs.result }} |
| 92 | + project-version: ${{ steps.check.outputs.project-version }} |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v2 |
| 95 | + - name: Set up Python |
| 96 | + uses: actions/setup-python@v2 |
| 97 | + with: |
| 98 | + python-version: "3.10" |
| 99 | + - name: Install poetry and package |
| 100 | + run: | |
| 101 | + pip install --use-deprecated legacy-resolver poetry telstra.messaging |
| 102 | + - name: Check if release is required |
| 103 | + id: check |
| 104 | + run: | |
| 105 | + RELEASED_VERSION=$(python -c "from importlib.metadata import version;print(version('telstra.messaging'))") |
| 106 | + echo released version: $RELEASED_VERSION |
| 107 | + PROJECT_VERSION=$(poetry version -s) |
| 108 | + echo project version: $PROJECT_VERSION |
| 109 | + [[ "$RELEASED_VERSION" == "$PROJECT_VERSION" ]] && RESULT=false || RESULT=true |
| 110 | + echo release required: $RESULT |
| 111 | + echo "::set-output name=project-version::$PROJECT_VERSION" |
| 112 | + echo "::set-output name=result::$RESULT" |
| 113 | +
|
| 114 | + # release-test-pypi: |
| 115 | + # runs-on: ubuntu-latest |
| 116 | + # needs: |
| 117 | + # - test |
| 118 | + # - build |
| 119 | + # - pre-commit |
| 120 | + # - release-required |
| 121 | + # steps: |
| 122 | + # - name: Retrieve packages |
| 123 | + # if: needs.release-required.outputs.result == 'true' |
| 124 | + |
| 125 | + # with: |
| 126 | + # name: wheel |
| 127 | + # path: dist/ |
| 128 | + # - name: Publish distribution 📦 to Test PyPI |
| 129 | + # if: needs.release-required.outputs.result == 'true' |
| 130 | + |
| 131 | + # with: |
| 132 | + # password: ${{ secrets.SECRET_PUBLISH_AS_TELSTRA_TEST_PYPI_ORG }} |
| 133 | + # repository_url: https://test.pypi.org/legacy/ |
| 134 | + |
| 135 | + # test-production-test-pypi: |
| 136 | + # runs-on: ubuntu-latest |
| 137 | + # needs: |
| 138 | + # - release-test-pypi |
| 139 | + # - release-required |
| 140 | + # steps: |
| 141 | + # - uses: actions/checkout@v2 |
| 142 | + # - name: Set up Python |
| 143 | + # uses: actions/setup-python@v2 |
| 144 | + # with: |
| 145 | + # python-version: "3.10" |
| 146 | + # - name: install pipenv |
| 147 | + # run: | |
| 148 | + # python -m pip install --upgrade pip |
| 149 | + # pip install pipenv |
| 150 | + # - name: install dependencies |
| 151 | + # env: |
| 152 | + # PYPI_MIRROR: https://test.pypi.org/simple/ |
| 153 | + # VERSION: ${{ needs.release-required.outputs.project-version }} |
| 154 | + # working-directory: production-test |
| 155 | + # run: | |
| 156 | + # pipenv install --dev || sleep 30 && pipenv install --dev || sleep 30 && pipenv install --dev || sleep 30 && pipenv install --dev |
| 157 | + # - name: run tests |
| 158 | + # working-directory: production-test |
| 159 | + # env: |
| 160 | + # TELSTRA_CLIENT_ID: ${{ secrets.PR_TEST_CLIENT_ID_MESSAGING }} |
| 161 | + # TELSTRA_CLIENT_SECRET: ${{ secrets.PR_TEST_CLIENT_SECRET_MESSAGING }} |
| 162 | + # run: | |
| 163 | + # pipenv run test |
| 164 | + |
| 165 | + release-pypi: |
| 166 | + runs-on: ubuntu-latest |
| 167 | + needs: |
| 168 | + # - test-production-test-pypi |
| 169 | + - release-required |
| 170 | + steps: |
| 171 | + - name: Retrieve packages |
| 172 | + if: needs.release-required.outputs.result == 'true' |
| 173 | + |
| 174 | + with: |
| 175 | + name: wheel |
| 176 | + path: dist/ |
| 177 | + - name: Publish distribution 📦 to PyPI |
| 178 | + if: needs.release-required.outputs.result == 'true' |
| 179 | + |
| 180 | + with: |
| 181 | + password: ${{ secrets.SECRET_PUBLISH_AS_TELSTRA_PYPI_ORG }} |
| 182 | + |
| 183 | + # test-production-pypi: |
| 184 | + # runs-on: ubuntu-latest |
| 185 | + # needs: |
| 186 | + # - release-pypi |
| 187 | + # - release-required |
| 188 | + # steps: |
| 189 | + # - uses: actions/checkout@v2 |
| 190 | + # - name: Set up Python |
| 191 | + # uses: actions/setup-python@v2 |
| 192 | + # with: |
| 193 | + # python-version: "3.10" |
| 194 | + # - name: install pipenv |
| 195 | + # run: | |
| 196 | + # python -m pip install --upgrade pip |
| 197 | + # pip install pipenv |
| 198 | + # - name: install dependencies |
| 199 | + # env: |
| 200 | + # PYPI_MIRROR: https://pypi.org/simple/ |
| 201 | + # VERSION: ${{ needs.release-required.outputs.project-version }} |
| 202 | + # working-directory: production-test |
| 203 | + # run: | |
| 204 | + # pipenv install --dev || sleep 30 && pipenv install --dev || sleep 30 && pipenv install --dev || sleep 30 && pipenv install --dev |
| 205 | + # - name: run tests |
| 206 | + # working-directory: production-test |
| 207 | + # env: |
| 208 | + # TELSTRA_CLIENT_ID: ${{ secrets.PR_TEST_CLIENT_ID_MESSAGING }} |
| 209 | + # TELSTRA_CLIENT_SECRET: ${{ secrets.PR_TEST_CLIENT_SECRET_MESSAGING }} |
| 210 | + # run: | |
| 211 | + # pipenv run test |
0 commit comments