CircleCI能否更换配置重新构建?可调整测试执行顺序吗?
Absolutely, let's break down how to address both of your requests clearly:
1. Swapping the Order of flake8 and Django Test Commands
To fix the issue where you can't see Django test errors first, you just need to adjust the order of your run commands in your CircleCI configuration file (typically located at .circleci/config.yml).
Here’s what your original test job might look like:
jobs: test: docker: - image: circleci/python:3.9 steps: - checkout - run: python -m venv venv - run: . venv/bin/activate && pip install -r requirements.txt - run: . venv/bin/activate && flake8 . # Runs first currently - run: . venv/bin/activate && python manage.py test # Runs second
Simply reorder the two run steps so the Django test runs before flake8:
jobs: test: docker: - image: circleci/python:3.9 steps: - checkout - run: python -m venv venv - run: . venv/bin/activate && pip install -r requirements.txt - run: . venv/bin/activate && python manage.py test # Now runs first - run: . venv/bin/activate && flake8 . # Now runs second
With this change, the Django test suite will execute first, so you’ll immediately see any test failures in your build logs before the flake8 code style check runs.
2. Does CircleCI Support Re-running Builds with Updated Config?
Yes, absolutely! There are two straightforward ways to do this:
- Push updated config to your repository: Once you edit and save the
.circleci/config.ymlfile, push the changes to your Git repo. CircleCI will automatically detect the update and trigger a new build using the modified configuration. - Rerun an existing build manually: If you want to re-run a previous build (after updating the config), navigate to the build in your CircleCI project dashboard. Click the Rerun button in the top-right corner—you can choose to rerun the entire workflow or just specific jobs.
Either way, your adjusted test order will take effect in the new build.
内容的提问来源于stack exchange,提问作者Kurt Peek

