@@ -77,10 +77,117 @@ jobs:
77
77
working-directory : ${{ inputs.working-directory }}
78
78
secrets : inherit
79
79
80
+ pre-release-checks :
81
+ needs :
82
+ - build
83
+ - test-pypi-publish
84
+ runs-on : ubuntu-latest
85
+ steps :
86
+ - uses : actions/checkout@v4
87
+
88
+ # We explicitly *don't* set up caching here. This ensures our tests are
89
+ # maximally sensitive to catching breakage.
90
+ #
91
+ # For example, here's a way that caching can cause a falsely-passing test:
92
+ # - Make the langchain package manifest no longer list a dependency package
93
+ # as a requirement. This means it won't be installed by `pip install`,
94
+ # and attempting to use it would cause a crash.
95
+ # - That dependency used to be required, so it may have been cached.
96
+ # When restoring the venv packages from cache, that dependency gets included.
97
+ # - Tests pass, because the dependency is present even though it wasn't specified.
98
+ # - The package is published, and it breaks on the missing dependency when
99
+ # used in the real world.
100
+
101
+ - name : Set up Python + Poetry ${{ env.POETRY_VERSION }}
102
+ uses : " ./.github/actions/poetry_setup"
103
+ with :
104
+ python-version : ${{ env.PYTHON_VERSION }}
105
+ poetry-version : ${{ env.POETRY_VERSION }}
106
+ working-directory : ${{ inputs.working-directory }}
107
+
108
+ - name : Import published package
109
+ shell : bash
110
+ working-directory : ${{ inputs.working-directory }}
111
+ env :
112
+ PKG_NAME : ${{ needs.build.outputs.pkg-name }}
113
+ VERSION : ${{ needs.build.outputs.version }}
114
+ # Here we use:
115
+ # - The default regular PyPI index as the *primary* index, meaning
116
+ # that it takes priority (https://pypi.org/simple)
117
+ # - The test PyPI index as an extra index, so that any dependencies that
118
+ # are not found on test PyPI can be resolved and installed anyway.
119
+ # (https://test.pypi.org/simple). This will include the PKG_NAME==VERSION
120
+ # package because VERSION will not have been uploaded to regular PyPI yet.
121
+ # - attempt install again after 5 seconds if it fails because there is
122
+ # sometimes a delay in availability on test pypi
123
+ run : |
124
+ poetry run pip install \
125
+ --extra-index-url https://test.pypi.org/simple/ \
126
+ "$PKG_NAME==$VERSION" || \
127
+ ( \
128
+ sleep 5 && \
129
+ poetry run pip install \
130
+ --extra-index-url https://test.pypi.org/simple/ \
131
+ "$PKG_NAME==$VERSION" \
132
+ )
133
+
134
+ # Replace dashes in the package name with underscores.
135
+ IMPORT_NAME="${PKG_NAME//-/_}"
136
+
137
+ poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
138
+
139
+ - name : Import test dependencies
140
+ run : poetry install --with dev
141
+ working-directory : ${{ inputs.working-directory }}
142
+
143
+ # Overwrite the local version of the package with the test PyPI version.
144
+ - name : Import published package (again)
145
+ working-directory : ${{ inputs.working-directory }}
146
+ shell : bash
147
+ env :
148
+ PKG_NAME : ${{ needs.build.outputs.pkg-name }}
149
+ VERSION : ${{ needs.build.outputs.version }}
150
+ run : |
151
+ poetry run pip install \
152
+ --extra-index-url https://test.pypi.org/simple/ \
153
+ "$PKG_NAME==$VERSION"
154
+
155
+ - name : Run unit tests
156
+ env :
157
+ MINDS_API_KEY : ${{ secrets.MINDS_API_KEY }}
158
+ run : make tests
159
+ working-directory : ${{ inputs.working-directory }}
160
+
161
+ - name : Run integration tests
162
+ env :
163
+ MINDS_API_KEY : ${{ secrets.MINDS_API_KEY }}
164
+ run : make integration_tests
165
+ working-directory : ${{ inputs.working-directory }}
166
+
167
+ - name : Get minimum versions
168
+ working-directory : ${{ inputs.working-directory }}
169
+ id : min-version
170
+ run : |
171
+ poetry run pip install packaging
172
+ min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
173
+ echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
174
+ echo "min-versions=$min_versions"
175
+
176
+ - name : Run unit tests with minimum dependency versions
177
+ if : ${{ steps.min-version.outputs.min-versions != '' }}
178
+ env :
179
+ MIN_VERSIONS : ${{ steps.min-version.outputs.min-versions }}
180
+ MINDS_API_KEY : ${{ secrets.MINDS_API_KEY }}
181
+ run : |
182
+ poetry run pip install $MIN_VERSIONS
183
+ make tests
184
+ working-directory : ${{ inputs.working-directory }}
185
+
80
186
publish :
81
187
needs :
82
188
- build
83
189
- test-pypi-publish
190
+ - pre-release-checks
84
191
runs-on : ubuntu-latest
85
192
permissions :
86
193
# This permission is used for trusted publishing:
@@ -123,6 +230,7 @@ jobs:
123
230
needs :
124
231
- build
125
232
- test-pypi-publish
233
+ - pre-release-checks
126
234
- publish
127
235
runs-on : ubuntu-latest
128
236
permissions :
0 commit comments