feat(workflow): improves cache and removes the need for --allow-dirty

Update prod.yml

Update .gitignore

feat(workflow): refactor that shuttle deploy works without dirty

ref(workflow): packages whole project for deployment

fix(workflow): ignore failed read on packaging

fix(workflow): package whole dir instead of zipping it

fix(workflow): fix invalid artifact name in job deploy

feat(workflow): refactor that shuttle deploy works without dirty (#34)

* feat(workflow): refactor that shuttle deploy works without dirty

* ref(workflow): packages whole project for deployment

* fix(workflow): ignore failed read on packaging

* fix(workflow): package whole dir instead of zipping it

* fix(workflow): fix invalid artifact name in job deploy

fix(workflow): invalid files in cache key

fix(workflow): cache not working
This commit is contained in:
itsscb 2024-09-06 14:36:38 +02:00
parent 1383885e8f
commit 3eba25740c
5 changed files with 113 additions and 40 deletions

View File

@ -14,37 +14,46 @@ jobs:
- name: checkout
uses: actions/checkout@v4
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: cache trunk
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/trunk
~/.cache/trunk/
key: ${{ runner.os }}-cargo-${{ hashFiles('~/.cargo/bin/trunk') }}
restore-keys: ${{ runner.os }}-trunk
- name: cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/
~/.rustup/
~/.cargo/registry/
~/.cargo/bin/
~/.cache/trunk/
frontend/target/
frontend/node_modules/
target/
node_modules/
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock', '~/.cargo/bin/trunk', './frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-cargo-wordl
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
- name: add rust target wasm32-unknown-unknown
run: rustup target add wasm32-unknown-unknown
- name: run frontend tests
working-directory: ./frontend/
run: |
cargo test
- name: run backend tests
working-directory: .
run: |
cargo test
- name: install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: install trunk
run: cargo install trunk
run: |
cargo binstall trunk --no-confirm
- name: install node.js
uses: actions/setup-node@v4
@ -52,51 +61,65 @@ jobs:
node-version: 20
- name: install tailwindcss
run: npm install -g tailwindcss
working-directory: ./frontend/
run: |
npm i -D
- name: list frontend dir (pre build) [DEBUG]
run: ls -la ./frontend/dist
- name: create ./frontend/dist dir
run: mkdir -p ./frontend/dist
- name: build frontend
working-directory: ./frontend/
run: |
sed -i 's/tailwindcss/npx/' Trunk.toml
sed -i 's/command_arguments \= \[/command_arguments \= \[\"tailwindcss\",/' Trunk.toml
cat Trunk.toml
sed -i '/frontend\/public\/styles.css/s/^/#/' ../.gitignore
trunk build --release
- name: list frontend dir (pre upload) [DEBUG]
run: ls -la ./frontend/dist
- name: upload frontend artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-artifacts
path: ./frontend/dist
- name: run tests
run: |
cargo test --verbose
deploy:
runs-on: ubuntu-latest
needs: build
steps:
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: remove ./frontend/dist dir
run: |
rm -rf ./frontend/dist
- name: download frontend artifacts
uses: actions/download-artifact@v4
with:
name: frontend-artifacts
path: ./frontend/dist
- name: remove items from .gitignore
run: |
sed -i '/frontend\/dist\//s/^/#/' .gitignore
sed -i '/frontend\/public\/styles.css/s/^/#/' .gitignore
- name: commit frontend build
run: |
git add frontend/dist -f
git add .gitignore
git commit -m "[${{github.run_attempt }}] ${{github.event.pusher}} > ${{ github.repository }}@${{ github.event.head_commit}}" || echo "No changes to commit"
- name: List downloaded artifacts
run: ls -la ./frontend/dist
run: ls -laR ./frontend/dist
- uses: shuttle-hq/deploy-action@main
with:
# allow-dirty: "true"
deploy-key: ${{ secrets.SHUTTLE_API_KEY }}
working-directory: .

41
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,41 @@
on:
pull_request:
branches:
- master
permissions:
contents: write
issues: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: cache dependencies
uses: actions/cache@v4
with:
path: |
~/.rustup/
~/.cargo/registry/
~/.cargo/bin/
~/.cache/trunk/
frontend/target/
target/
frontend/node_modules/
node_modules/
key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock', '~/.cargo/bin/trunk', './frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-cargo-wordl
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
- name: run frontend tests
working-directory: ./frontend/
run: |
cargo test

6
.gitignore vendored
View File

@ -6,6 +6,12 @@ target/
frontend/target/
frontend/dist/
frontend/public/styles.css
node_modules/
frontend/node_modules/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# Cargo.lock

View File

@ -1,11 +1,12 @@
{
"name": "wordl",
"name": "wordl-frontend",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "wordl-frontend",
"devDependencies": {
"tailwindcss": "^3.4.3"
"tailwindcss": "^3.4.10"
}
},
"node_modules/@alloc/quick-lru": {
@ -1176,10 +1177,11 @@
}
},
"node_modules/tailwindcss": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz",
"integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==",
"version": "3.4.10",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.10.tgz",
"integrity": "sha512-KWZkVPm7yJRhdu4SRSl9d4AK2wM3a50UsvgHZO7xY77NQr2V+fIrEuoDGQcbvswWvFGbS2f6e+jC/6WJm1Dl0w==",
"dev": true,
"license": "MIT",
"dependencies": {
"@alloc/quick-lru": "^5.2.0",
"arg": "^5.0.2",

View File

@ -1,5 +1,6 @@
{
"name": "wordl-frontend",
"devDependencies": {
"tailwindcss": "^3.4.3"
"tailwindcss": "^3.4.10"
}
}