Merge branch 'main' of https://github.com/mcmod-info-mirror/mcim-rust… #8
This file contains hidden or 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: "Test and build" | |
| on: | |
| push: | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'data/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'Dockerfile' | |
| - '.dockerignore' | |
| - 'justfile' | |
| - '.github/workflows/**' | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'data/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'Dockerfile' | |
| - '.dockerignore' | |
| - 'justfile' | |
| - '.github/workflows/**' | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| env: | |
| CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install just | |
| uses: extractions/setup-just@v2 | |
| - name: Start MongoDB | |
| uses: supercharge/[email protected] | |
| - name: Start Redis | |
| uses: supercharge/[email protected] | |
| - name: Install MongoDB Database Tools | |
| run: | | |
| curl -O https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2404-x86_64-100.12.2.deb | |
| sudo dpkg -i mongodb-database-tools-ubuntu2404-x86_64-100.12.2.deb | |
| sudo apt-get install -f -y | |
| - name: Install Redis tool | |
| run: | | |
| sudo apt-get install lsb-release curl gpg | |
| curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg | |
| sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list | |
| sudo apt-get update | |
| sudo apt install redis-tools | |
| - name: Install dependencies | |
| run: | | |
| just import-data | |
| - name: Run tests | |
| run: cargo test --verbose | |
| # build: | |
| # needs: "test" | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - uses: actions/checkout@v4 | |
| # - name: Cache Cargo | |
| # uses: Swatinem/rust-cache@v2 | |
| # - name: build | |
| # run: | | |
| # cargo build --release --verbose --bin mcim-rust-api | |
| # - name: Upload Artifact | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: build-artifact | |
| # path: target/release/mcim-rust-api | |
| # docker_build: | |
| # needs: "test" | |
| # runs-on: ubuntu-latest | |
| # if: github.event_name != 'pull_request' | |
| # steps: | |
| # - name: Checkout | |
| # uses: actions/checkout@v4 | |
| # - name: Extract Docker image metadata | |
| # id: meta | |
| # uses: docker/metadata-action@v5 | |
| # with: | |
| # images: ${{ vars.DOCKER_USERNAME }}/mcim-rust-api | |
| # tags: | | |
| # type=sha,format=short,prefix= | |
| # latest | |
| # - name: Log in to Docker Hub | |
| # uses: docker/login-action@v3 | |
| # with: | |
| # username: ${{ vars.DOCKER_USERNAME }} | |
| # password: ${{ secrets.DOCKER_PASSWORD }} | |
| # - name: Set up Docker Buildx | |
| # uses: docker/setup-buildx-action@v3 | |
| # - name: Build and push Docker image | |
| # uses: docker/build-push-action@v6 | |
| # with: | |
| # push: ${{ github.event_name != 'pull_request' }} | |
| # platforms: linux/amd64,linux/arm64 | |
| # tags: ${{ steps.meta.outputs.tags }} | |
| # annotations: ${{ steps.meta.outputs.annotations }} | |
| # cache-from: type=gha | |
| # cache-to: type=gha,mode=max | |
| build_and_docker: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build Rust Binary | |
| run: | | |
| cargo build --release --verbose --bin mcim-rust-api | |
| cargo build --verbose --bin mcim-rust-api | |
| mkdir -p build_output | |
| cp target/release/mcim-rust-api build_output/mcim-rust-api | |
| cp target/debug/mcim-rust-api build_output/mcim-rust-api-debug | |
| - name: Upload Rust Binary Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifact | |
| path: build_output/ | |
| - name: Extract Docker image metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ vars.DOCKER_USERNAME }}/mcim-rust-api | |
| tags: | | |
| type=sha,format=short,prefix= | |
| latest | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| annotations: ${{ steps.meta.outputs.annotations }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |