forked from Ruderverein-Donau-Linz/rowt
		
	optimize ci build: use own dockerfile for dependencies + cache for builds (#164)
Reviewed-on: Ruderverein-Donau-Linz/rowt#164
This commit is contained in:
		| @@ -7,29 +7,35 @@ env: | ||||
|   SSH_HOST: ${{ secrets.SSH_HOST }} | ||||
|   SSH_USER: ${{ secrets.SSH_USER }} | ||||
|   SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||||
|   CARGO_INCREMENTAL: 0 | ||||
|  | ||||
| jobs: | ||||
|   test-frontend: | ||||
|   test: | ||||
|     runs-on: ubuntu-latest | ||||
|     container: rust:latest | ||||
|     container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240118 | ||||
|     steps: | ||||
|     - name: Setup Environment | ||||
|       run: | | ||||
|         apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools sqlite3 curl gnupg && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y | ||||
|     - uses: actions/checkout@v3 | ||||
|     - name: Run Test DB Script | ||||
|       run: ./test_db.sh | ||||
|  | ||||
|     - name: Set up cargo cache | ||||
|       uses: actions/cache@v3 | ||||
|       with: | ||||
|         path: | | ||||
|           ~/.cargo/bin/ | ||||
|           ~/.cargo/registry/index/ | ||||
|           ~/.cargo/registry/cache/ | ||||
|           ~/.cargo/git/db/ | ||||
|           target/ | ||||
|         key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||||
|  | ||||
|     - name: Build | ||||
|       run: | | ||||
|         cargo build  | ||||
|         cd frontend && npm install && npm run build | ||||
|     - name: Install dependencies | ||||
|       run: cd frontend && npm install | ||||
|     - name: Install Playwright Browsers | ||||
|       run: cd frontend && npx playwright install --with-deps | ||||
|     - name: Run Playwright tests | ||||
|     - name: Frontend tests | ||||
|       run: cd frontend && npx playwright test --workers 1 | ||||
|     - name: Backend tests | ||||
|       run: cargo test --verbose | ||||
|     #- uses: actions/upload-artifact@v3 | ||||
|     #  if: always() | ||||
|     #  with: | ||||
| @@ -37,61 +43,30 @@ jobs: | ||||
|     #    path: frontend/playwright-report/ | ||||
|     #    retention-days: 30 | ||||
|  | ||||
|   test-backend: | ||||
|     runs-on: ubuntu-latest | ||||
|     container: rust:latest | ||||
|  | ||||
|     steps: | ||||
|       - name: Setup Environment | ||||
|         run: | | ||||
|           apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools sqlite3 curl gnupg && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y | ||||
|  | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|  | ||||
|       - name: Run Test DB Script | ||||
|         run: ./test_db.sh | ||||
|  | ||||
|       - name: Build | ||||
|         run: | | ||||
|           cargo build  | ||||
|           cd frontend && npm install && npm run build | ||||
|  | ||||
|       - name: Run Tests | ||||
|         run: cargo test --verbose | ||||
|  | ||||
|   deploy-staging: | ||||
|     runs-on: ubuntu-latest | ||||
|     container: rust:latest | ||||
|     needs: [test_frontend, test_backend] | ||||
|     container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240118 | ||||
|     needs: [test] | ||||
|     if: github.ref == 'refs/heads/staging' | ||||
|     steps: | ||||
|       - name: Setup Environment | ||||
|         run: | | ||||
|           rustup target add $CARGO_TARGET | ||||
|           apt-get update -qq && apt-get install -y -qq pkg-config sshpass musl musl-tools sqlite3 curl gnupg libssl-dev | ||||
|            | ||||
|           # Handling NodeSource GPG key | ||||
|           curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o nodesource.gpg.key | ||||
|           if [ -f /etc/apt/keyrings/nodesource.gpg ]; then | ||||
|               rm /etc/apt/keyrings/nodesource.gpg | ||||
|           fi | ||||
|           gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg nodesource.gpg.key | ||||
|  | ||||
|           # Adding NodeSource repository | ||||
|           echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list | ||||
|            | ||||
|           # Installing Node.js and npm | ||||
|           apt-get update | ||||
|           apt-get install nodejs -y | ||||
|           apt-get install npm -y | ||||
|  | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|        | ||||
|       - name: Run Test DB Script | ||||
|         run: ./test_db.sh | ||||
|  | ||||
|       - name: Set up cargo cache | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: | | ||||
|             ~/.cargo/bin/ | ||||
|             ~/.cargo/registry/index/ | ||||
|             ~/.cargo/registry/cache/ | ||||
|             ~/.cargo/git/db/ | ||||
|             target/ | ||||
|           key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||||
|  | ||||
|       - name: Build | ||||
|         run: | | ||||
|           cargo build --release --target $CARGO_TARGET | ||||
| @@ -122,20 +97,26 @@ jobs: | ||||
|  | ||||
|   deploy-main: | ||||
|     runs-on: ubuntu-latest | ||||
|     container: rust:latest | ||||
|     needs: [test_frontend, test_backend] | ||||
|     container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240118 | ||||
|     needs: [test] | ||||
|     if: github.ref == 'refs/heads/main' | ||||
|     steps: | ||||
|       - name: Setup Environment | ||||
|         run: | | ||||
|           rustup target add $CARGO_TARGET | ||||
|           apt-get update -qq && apt-get install -y -qq pkg-config sshpass musl musl-tools sqlite3 curl gnupg libssl-dev && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y | ||||
|  | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v3 | ||||
|        | ||||
|       - name: Run Test DB Script | ||||
|         run: ./test_db.sh | ||||
|        | ||||
|       - name: Set up cargo cache | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: | | ||||
|             ~/.cargo/bin/ | ||||
|             ~/.cargo/registry/index/ | ||||
|             ~/.cargo/registry/cache/ | ||||
|             ~/.cargo/git/db/ | ||||
|             target/ | ||||
|           key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||||
|  | ||||
|       - name: Build | ||||
|         run: | | ||||
|   | ||||
		Reference in New Issue
	
	Block a user