name: Check code style and build on: push: branches: - main pull_request: defaults: run: shell: bash -euxo pipefail {0} concurrency: # Allow only one workflow per any non-`main` branch. group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || 'anysha' }} cancel-in-progress: true env: RUST_BACKTRACE: 1 COPT: '-Werror' jobs: check-codestyle-rust: strategy: fail-fast: false matrix: # XXX: both OSes have rustup # * https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#rust-tools # * https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#rust-tools # this is all we need to install our toolchain later via rust-toolchain.toml # so don't install any toolchain explicitly. os: [ubuntu-latest, macos-latest] timeout-minutes: 90 name: check codestyle rust and postgres runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 with: submodules: true fetch-depth: 2 - name: Check formatting run: cargo fmt --all -- --check - name: Install Ubuntu postgres dependencies if: matrix.os == 'ubuntu-latest' run: | sudo apt update sudo apt install build-essential libreadline-dev zlib1g-dev flex bison libseccomp-dev libssl-dev - name: Install macOS postgres dependencies if: matrix.os == 'macos-latest' run: brew install flex bison openssl - name: Set pg 14 revision for caching id: pg_v14_rev run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v14) >> $GITHUB_OUTPUT shell: bash -euxo pipefail {0} - name: Set pg 15 revision for caching id: pg_v15_rev run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v15) >> $GITHUB_OUTPUT shell: bash -euxo pipefail {0} - name: Cache postgres v14 build id: cache_pg_14 uses: actions/cache@v3 with: path: pg_install/v14 key: v1-${{ runner.os }}-${{ matrix.build_type }}-pg-${{ steps.pg_v14_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} - name: Cache postgres v15 build id: cache_pg_15 uses: actions/cache@v3 with: path: pg_install/v15 key: v1-${{ runner.os }}-${{ matrix.build_type }}-pg-${{ steps.pg_v15_rev.outputs.pg_rev }}-${{ hashFiles('Makefile') }} - name: Set extra env for macOS if: matrix.os == 'macos-latest' run: | echo 'LDFLAGS=-L/usr/local/opt/openssl@3/lib' >> $GITHUB_ENV echo 'CPPFLAGS=-I/usr/local/opt/openssl@3/include' >> $GITHUB_ENV - name: Build postgres v14 if: steps.cache_pg_14.outputs.cache-hit != 'true' run: make postgres-v14 shell: bash -euxo pipefail {0} - name: Build postgres v15 if: steps.cache_pg_15.outputs.cache-hit != 'true' run: make postgres-v15 shell: bash -euxo pipefail {0} - name: Build neon extensions run: make neon-pg-ext - name: Cache cargo deps id: cache_cargo uses: actions/cache@v3 with: path: | ~/.cargo/registry !~/.cargo/registry/src ~/.cargo/git target key: v5-${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}-rust - name: Run cargo clippy run: ./run_clippy.sh - name: Ensure all project builds run: cargo build --locked --all --all-targets check-rust-dependencies: runs-on: dev container: image: 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:pinned options: --init steps: - name: Checkout uses: actions/checkout@v3 with: submodules: false fetch-depth: 1 # https://github.com/facebookincubator/cargo-guppy/tree/bec4e0eb29dcd1faac70b1b5360267fc02bf830e/tools/cargo-hakari#2-keep-the-workspace-hack-up-to-date-in-ci - name: Check every project module is covered by Hakari run: | cargo hakari generate --diff # workspace-hack Cargo.toml is up-to-date cargo hakari manage-deps --dry-run # all workspace crates depend on workspace-hack shell: bash -euxo pipefail {0} check-codestyle-python: runs-on: [ self-hosted, Linux, k8s-runner ] steps: - name: Checkout uses: actions/checkout@v3 with: submodules: false fetch-depth: 1 - name: Cache poetry deps id: cache_poetry uses: actions/cache@v3 with: path: ~/.cache/pypoetry/virtualenvs key: v1-codestyle-python-deps-${{ hashFiles('poetry.lock') }} - name: Install Python deps run: ./scripts/pysync - name: Run isort to ensure code format run: poetry run isort --diff --check . - name: Run black to ensure code format run: poetry run black --diff --check . - name: Run flake8 to ensure code format run: poetry run flake8 . - name: Run mypy to check types run: poetry run mypy .