fix(python): replace lzma with xz when using nix (#743) #1918
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous testing | |
on: | |
# Runs on a push | |
push: | |
branches: | |
- main | |
# Runs on a pull request | |
pull_request: | |
branches: | |
- main | |
# Allows to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
# Hosted GitHub runners have 7 GB of memory available, let's use 6 GB | |
NODE_OPTIONS: --max-old-space-size=6144 | |
jobs: | |
check-changed-files: | |
name: Check changed files | |
runs-on: ubuntu-latest | |
outputs: | |
deploy_website: ${{ steps.changed-files.outputs.website_any_modified }} | |
trigger_algolia: ${{ steps.changed-files.outputs.website_contents_any_modified }} | |
run_tests: ${{ steps.changed-files.outputs.core_any_modified }} | |
pages_environment: ${{ env.PAGES_ENVIRONMENT }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get changes core and website files | |
id: changed-files | |
uses: tj-actions/changed-files@v45 | |
with: | |
files_yaml: | | |
website: | |
- '.github/workflows/tests.yaml' | |
- 'website/**' | |
website_contents: | |
- 'website/contents/**' | |
core: | |
- '.github/workflows/build.yaml' | |
- '.github/workflows/build-and-test-target.yaml' | |
- '.github/workflows/tests.yaml' | |
- 'Cargo.lock' | |
- 'Cargo.toml' | |
- 'build.rs' | |
- 'templates/**' | |
- 'src/**' | |
- 'tests/**' | |
- name: List all changed files | |
run: | | |
for file in ${{ steps.changed-files.outputs.website_all_modified_files }}; do | |
echo "website: $file was modified" | |
done | |
for file in ${{ steps.changed-files.outputs.core_all_modified_files }}; do | |
echo "core: $file was modified" | |
done | |
- name: Set the pages environment | |
if: github.event_name != 'pull_request' | |
run: | | |
echo "PAGES_ENVIRONMENT=github-pages" | tee -a "$GITHUB_ENV" | |
prepare-release-version: | |
name: Prepare build version | |
runs-on: ubuntu-latest | |
needs: | |
- check-changed-files | |
if: needs.check-changed-files.outputs.run_tests == 'true' | |
outputs: | |
release_version: ${{ env.RELEASE_VERSION }} | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v4 | |
- name: Get release version | |
run: | | |
git fetch --append --tags --unshallow --force | |
RELEASE_VERSION=$(git describe --tags --broken --dirty --match v* 2>/dev/null || true) | |
[ -z "$RELEASE_VERSION" ] && \ | |
RELEASE_VERSION=0.0.0-g$(git describe --tags --always --broken --dirty --match v*) | |
RELEASE_VERSION=${RELEASE_VERSION##v} | |
echo "RELEASE_VERSION=${RELEASE_VERSION}" | tee -a "$GITHUB_ENV" | |
build-and-test-binaries: | |
name: Build and test binaries | |
needs: | |
- prepare-release-version | |
uses: ./.github/workflows/build.yaml | |
with: | |
git_sha: ${{ github.sha }} | |
release_version: ${{ needs.prepare-release-version.outputs.release_version }} | |
sign: false | |
rust-clippy-analysis: | |
name: Run rust-clippy analysis | |
runs-on: ubuntu-latest | |
needs: | |
- prepare-release-version | |
permissions: | |
contents: read | |
security-events: write | |
actions: read | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- name: Set up cargo cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: clippy | |
- name: Install required cargo | |
run: cargo install clippy-sarif sarif-fmt | |
- name: Run clippy | |
id: clippy | |
run: | | |
cargo clippy --all-features --message-format=json | \ | |
clippy-sarif | \ | |
tee rust-clippy-results.sarif | \ | |
sarif-fmt | |
continue-on-error: true | |
- name: Upload analysis results to GitHub | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: rust-clippy-results.sarif | |
wait-for-processing: true | |
- name: Fail if clippy failed | |
run: | | |
# Fail if the SARIF file is empty | |
if [ ! -s rust-clippy-results.sarif ]; then | |
exit 1 | |
fi | |
# Count the number of warnings and errors | |
results=$(jq \ | |
'.runs[] | |
| select(.tool.driver.name == "clippy") | |
| .results | |
| length' \ | |
rust-clippy-results.sarif) | |
# Fail if there are any warnings or errors | |
if [[ "$results" != "0" ]]; then | |
echo >&2 "Clippy found $results warnings or errors" | |
exit 1 | |
fi | |
deploy-website: | |
name: Deploy static content | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ needs.check-changed-files.outputs.pages_environment }} | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: | |
- check-changed-files | |
if: needs.check-changed-files.outputs.deploy_website == 'true' | |
steps: | |
- name: Checkout current commit | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '>=18.0 <20.6.0 || >=20.6.1' | |
cache: yarn | |
cache-dependency-path: 'website/yarn.lock' | |
- name: Install dependencies | |
working-directory: website | |
run: yarn install --frozen-lockfile --non-interactive | |
- name: Build | |
working-directory: website | |
run: yarn build | |
- name: Setup Pages | |
if: github.event_name != 'pull_request' | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact | |
if: github.event_name != 'pull_request' | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: website/build | |
- name: Deploy to GitHub Pages | |
if: github.event_name != 'pull_request' | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
- name: Trigger Algolia crawler | |
if: github.event_name != 'pull_request' && needs.check-changed-files.outputs.trigger_algolia == 'true' | |
uses: algolia/[email protected] | |
with: | |
crawler-name: omnicli | |
crawler-user-id: ${{ secrets.ALGOLIA_CRAWLER_USER_ID }} | |
crawler-api-key: ${{ secrets.ALGOLIA_CRAWLER_API_KEY }} | |
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }} | |
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }} | |
site-url: ${{ steps.deployment.outputs.page_url }} | |
override-config: false | |
check-results: | |
name: Check tests results | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-test-binaries | |
- rust-clippy-analysis | |
- deploy-website | |
if: '!cancelled()' | |
steps: | |
- name: Fail if tests failed | |
if: needs.build-and-test-binaries.result == 'failure' || needs.build-and-test-binaries.result == 'cancelled' | |
run: exit 1 | |
- name: Fail if CodeQL failed | |
if: needs.rust-clippy-analysis.result == 'failure' || needs.rust-clippy-analysis.result == 'cancelled' | |
run: exit 1 | |
- name: Fail if website building/deployment failed | |
if: needs.deploy-website.result == 'failure' || needs.deploy-website.result == 'cancelled' | |
run: exit 1 | |
auto-merge: | |
name: Auto-merge Dependabot pull-requests | |
runs-on: ubuntu-latest | |
needs: | |
- check-results | |
if: always() && github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' && needs.check-results.result == 'success' | |
permissions: | |
contents: none | |
steps: | |
- name: Checkout current commit | |
uses: actions/checkout@v4 | |
- name: Enable auto-merge if Dependabot | |
env: | |
GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
run: | | |
gh pr merge --squash --auto --body "" "$PR_NUMBER" |