File: tests.yml

package info (click to toggle)
locust 2.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,828 kB
  • sloc: javascript: 52,230; python: 20,862; sh: 118; makefile: 29
file content (198 lines) | stat: -rw-r--r-- 7,291 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Tests

on: [push, pull_request]

permissions:
  contents: read

jobs:
  tests:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        include:
          - {name: Windows, python: '3.12', os: windows-latest, tox: fail_fast_test_main}
          # - {name: Mac, python: '3.12', os: macos-latest, tox: fail_fast_test_main}
          - { name: "ruff", python: "3.11", os: ubuntu-latest, tox: "ruff" }
          - { name: "mypy", python: "3.10", os: ubuntu-latest, tox: "mypy" }
          # run some integration tests and abort immediately if they fail, for faster feedback
          - { name: "Linux", python: "3.12", os: ubuntu-latest, tox: fail_fast_test_main }
          - { name: "3.12", python: "3.12", os: ubuntu-latest, tox: py312 }
          - { name: "3.11", python: "3.11", os: ubuntu-latest, tox: py311 }
          - { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 }
          - { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 }
          - { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 }

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}
      - name: Update pip
        run: |
          python -m pip install --upgrade pip
      - name: Get pip cache dir
        id: pip-cache
        run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
      - uses: actions/cache@v3
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('pyproject.toml') }}
      - name: set full Python version in PY env var
        # See https://pre-commit.com/#github-actions-example
        run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
      - run: python -m pip install tox
      - run: python -m tox -e ${{ matrix.tox }}

  lint_typecheck_test_webui:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set Node.js 18.x
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
      - uses: borales/actions-yarn@v3
        with:
          cmd: webui:install
      - uses: borales/actions-yarn@v3
        with:
          cmd: webui:build
      - uses: borales/actions-yarn@v3
        with:
          cmd: webui:test
      - uses: borales/actions-yarn@v3
        with:
          cmd: webui:lint
      - uses: borales/actions-yarn@v3
        with:
          cmd: webui:type-check

  verify_docker_build:
    name: Always - Docker verify, push to tag 'master' if on master
    runs-on: ubuntu-latest
    if: github.event_name != 'pull_request' # PR build doesnt get proper version, so dont try to build it
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - uses: docker/login-action@v1
        if: github.repository_owner == 'locustio'
        with:
          username: locustbuild
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: build and publish image
        id: docker_build
        uses: docker/build-push-action@v5
        with:
          build-args: |
            BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          push: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'locustio' }}
          tags: locustio/locust:master

  docker_tagged:
    name: Tagged - Docker push to tag based on git tag. Also push 'latest' if on master
    needs: tests
    runs-on: ubuntu-latest
    if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio'
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - run: echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
      - run: echo "BRANCH=$(git branch -a --contains ${{ env.TAG }} | grep -v HEAD | cut -d '/' -f3)" | tee -a $GITHUB_ENV
      - uses: docker/login-action@v1
        with:
          username: locustbuild
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: build and publish image
        id: docker_build
        uses: docker/build-push-action@v5
        with:
          build-args: |
            BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          push: true
          tags: locustio/locust:${{ env.TAG }}${{ ( env.BRANCH == 'master' && ',locustio/locust:latest') || '' }}

  publish:
    name: PyPI - Publish if this is a tagged commit
    needs: [verify_docker_build, tests]
    if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.x"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip build
      - name: Build + set TAG env var for later use
        run: |
          python -m build
          echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
      - name: Publish tagged version to PyPI
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true
    # The following is disabled because it has stopped working.
    #   - name: Tweet on release
    #     uses: infraway/tweet-action@v1.0.1
    #     with:
    #       status: "New release: ${{ env.TAG }} https://github.com/locustio/locust/releases/tag/${{ env.TAG }}"
    #       api_key: ${{ secrets.TWITTER_API_CONSUMER_KEY }}
    #       api_key_secret: ${{ secrets.TWITTER_API_CONSUMER_SECRET }}
    #       access_token: ${{ secrets.TWITTER_API_ACCESS_TOKEN_KEY }}
    #       access_token_secret: ${{ secrets.TWITTER_API_ACCESS_TOKEN_SECRET }}

  publish_prerelease:
    name: PyPI - Publish prerelease on merge commit on master
    needs: tests
    if: github.ref == 'refs/heads/master' && github.repository_owner == 'locustio'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.x"
      - run: git rev-parse HEAD^2 2>/dev/null >/dev/null || echo NOT_MERGE_COMMIT=1 | tee -a $GITHUB_ENV
      - name: Install dependencies
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        run: |
          python -m pip install --upgrade pip build
      - name: Build
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        run: |
          python -m build
      - name: Publish prerelease version to PyPI
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true