feat: workflow changes

This commit is contained in:
Eli Bosley
2024-10-23 22:16:14 -04:00
parent cf0eeebd31
commit 1c61e64169
4 changed files with 58 additions and 83 deletions

View File

@@ -32,8 +32,24 @@ jobs:
- name: Validate branch and tag
run: exit 0
build-register-container:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Build with Buildx
uses: docker/setup-buildx-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
install: true
platforms: linux/amd64
- name: Build Builder Image
run: docker buildx build -t builder -f ./Dockerfile .
lint-api:
continue-on-error: true
continue-on-error: false
defaults:
run:
working-directory: api
@@ -41,62 +57,43 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Build with Buildx
uses: docker/setup-buildx-action@v3
with:
persist-credentials: false
- name: Reconfigure git to use HTTP authenti:cation
run: >
git config --global url."https://github.com/".insteadOf
ssh://git@github.com/
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
install: true
platforms: linux/amd64
- name: Build Builder Image
run: docker buildx build -t builder -f ./Dockerfile .
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: "api/.nvmrc"
# - name: Get npm cache directory
# id: npm-cache
# run: echo "::set-output name=dir::$(npm config get cache)"
# - name: Load npm cache
# uses: actions/cache@v3
# with:
# path: ${{ steps.npm-cache.outputs.dir }}
# key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
- name: Install libvirt-dev
run: sudo apt-get update && sudo apt-get install libvirt-dev
- name: Installing node deps
run: npm install
- name: Lint files
run: npm run lint
- name: Lint inside of the docker container
run: |
docker run --rm builder npm run lint
test-api:
continue-on-error: false
defaults:
run:
working-directory: api
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Build with Buildx
uses: docker/setup-buildx-action@v3
with:
persist-credentials: false
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://git@github.com/
- name: Build Docker Compose
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
install: true
platforms: linux/amd64
- name: Build Builder Image
run: docker buildx build -t builder -f ./Dockerfile .
- name: Test inside of the docker container
run: |
docker network create mothership_default
GIT_SHA=$(git rev-parse --short HEAD) IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '') docker compose build builder
- name: Run Docker Compose
run: GIT_SHA=$(git rev-parse --short HEAD) IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '') docker compose run builder npm run coverage
docker run --rm builder npm run coverage
lint-web:
defaults:
run:
@@ -142,35 +139,22 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Add SSH deploy key
uses: shimataro/ssh-key-action@v2
- name: Build with Buildx
uses: docker/setup-buildx-action@v3
with:
key: ${{ secrets.UNRAID_BOT_SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: "api/.nvmrc"
- name: Install libvirt-dev
run: sudo apt-get update && sudo apt-get install libvirt-dev
- name: Installing node deps
run: npm install
- name: Install pkg and node-prune
run: npm i -g pkg && curl -sf https://gobinaries.com/tj/node-prune | sh
# See https://github.com/apollographql/subscriptions-transport-ws/issues/433
- name: Patch subscriptions-transport-ws
run: npm run patch:subscriptions-transport-ws
- name: Build and Pack
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
install: true
platforms: linux/amd64
- name: Build Builder Image
run: docker buildx build -t builder -f ./Dockerfile .
- name: Build inside of the docker container
id: build-pack-binary
run: WORKDIR=${{ github.workspace }} && npm run build-pkg
run: |
docker run --rm -v ${{ github.workspace }}/api/deploy/release:/app/deploy/release builder npm run build
API_VERSION=$(cat package.json | jq -r '.version')
echo "::set-output name=API_VERSION::${API_VERSION}"
- name: Set Hashes
id: set-hashes
@@ -316,10 +300,9 @@ jobs:
AWS_S3_BUCKET: ${{ secrets.CF_BUCKET_PREVIEW }}
AWS_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }}
AWS_REGION: 'auto'
AWS_REGION: "auto"
SOURCE_DIR: staging-release
DEST_DIR: unraid-api
create-draft-release:
# Only create new draft if this is a version tag

View File

@@ -20,10 +20,6 @@ WORKDIR /app
# Set app env
ENV NODE_ENV=development
# Setup cache for pkg
ENV PKG_CACHE_PATH /app/.pkg-cache
RUN mkdir -p ${PKG_CACHE_PATH}
COPY tsconfig.json .eslintrc.ts .npmrc .env.production .env.staging ./
COPY package.json package-lock.json ./
@@ -41,4 +37,4 @@ FROM development AS builder
COPY . .
CMD ["npm", "run", "build-pkg"]
CMD ["npm", "run", "build-and-pack"]

View File

@@ -4,11 +4,9 @@ x-volumes: &volumes
volumes:
- ./dev:/app/dev
- ./src:/app/src
- ./patches:/app/patches
- ./package.json:/app/package.json
- ./package-lock.json:/app/package-lock.json
- ./tsconfig.json:/app/tsconfig.json
- ./tsup.config.ts:/app/tsup.config.ts
- ./vite.config.ts:/app/vite.config.ts
- ./dist/:/app/dist/
- ./deploy/:/app/deploy/
@@ -19,7 +17,6 @@ x-volumes: &volumes
- ./.env.staging:/app/.env.staging
- ./.env.test:/app/.env.test
- ./.env.development:/app/.env.development
- ./.pkg-cache:/app/.pkg-cache
- ./codegen.yml:/app/codegen.yml
- ./fix-array-type.cjs:/app/fix-array-type.cjs
- /var/run/docker.sock:/var/run/docker.sock

View File

@@ -8,7 +8,7 @@
"license": "UNLICENSED",
"scripts": {
"build:docker": "./scripts/dc.sh run --rm builder",
"build:pack": "./scripts/build.mjs",
"build-and-pack": "./scripts/build.mjs",
"codegen": "MOTHERSHIP_GRAPHQL_LINK='https://staging.mothership.unraid.net/ws' graphql-codegen --config codegen.yml -r dotenv/config './.env.staging'",
"codegen:watch": "DOTENV_CONFIG_PATH='./.env.staging' graphql-codegen --config codegen.yml --watch -r dotenv/config",
"codegen:local": "NODE_TLS_REJECT_UNAUTHORIZED=0 MOTHERSHIP_GRAPHQL_LINK='https://mothership.localhost/ws' graphql-codegen-esm --config codegen.yml --watch",
@@ -18,7 +18,6 @@
"test:watch": "vitest --pool=forks",
"test": "vitest run --pool=forks",
"coverage": "vitest run --coverage",
"patch:subscriptions-transport-ws": "node ./.scripts/patches/subscriptions-transport-ws.cjs",
"release": "standard-version",
"install:unraid": "./scripts/install-in-unraid.sh",
"boot:unraid": "tsx -r dotenv/config src/index.ts",