Skip to content

Commit

Permalink
Merge pull request #2 from sapcc/hgw-build-release
Browse files Browse the repository at this point in the history
feat(ci): build release
  • Loading branch information
hgw77 authored Dec 18, 2024
2 parents 9c05e11 + f7cd887 commit 3a755dc
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: maillog-ui checks

on:
pull_request:
branches: ["main"]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm install
- run: npm test
51 changes: 51 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: package-release
on:
push:
branches:
- main
paths:
- package.json
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-and-publish:
runs-on: [ubuntu-latest]
env:
ACTIONS_RUNNER_DEBUG: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: https://npm.pkg.github.com/
# @sapcc
# this is the scope of the package to publish to the registry-url that is defined above
scope: "@${{ github.repository_owner }}"

- name: Install dependencies
run: npm install

- name: Test
run: npm run test

- name: Build
run: |
npm run build
ls -la
- name: Publish to github packages
run: |
set +e
# publish to https://github.com/${{ github.repository_owner }}/packages
npm publish --access=public # --dry-run
if [ $? != 0 ] ; then
echo "::warning title=PUBLISH::Could not publish to github. Maybe you forgot to increment the version?"
exit 0
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/setupTests.js"],
transformIgnorePatterns: [
"node_modules/(?!(juno-ui-components|url-state-router|communicator|url-state-provider|policy-engine)/)", // |messages-provider
"node_modules/(?!(@cloudoperators/juno-ui-components|@cloudoperators/juno-url-state-provider)|@cloudoperators/juno-communicator/)", // |messages-provider
],
moduleNameMapper: {
// Jest currently doesn't support resources with query parameters.
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"source": "src/index.js",
"module": "build/index.js",
"private": true,
"private": false,
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/preset-env": "^7.20.2",
Expand Down Expand Up @@ -45,9 +45,6 @@
"start": "PORT=$APP_PORT NODE_ENV=development node esbuild.config.js --serve --watch",
"build": "NODE_ENV=production node esbuild.config.js"
},
"importmapExtras": {
"zustand/middleware": "4.3.7"
},
"appProps": {
"theme": {
"value": "theme-light",
Expand Down
4 changes: 4 additions & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom"

// _getCurrentToken returns a promise
// _getCurrentToken is a function that returns a promise
window._getCurrentToken = jest.fn(() => Promise.resolve("token"))
3 changes: 2 additions & 1 deletion src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { render, act, waitFor } from "@testing-library/react"
import { render } from "@testing-library/react"
import { act } from "react"
// support shadow dom queries
// https://reactjsexample.com/an-extension-of-dom-testing-library-to-provide-hooks-into-the-shadow-dom/
import { screen } from "shadow-dom-testing-library"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/store/createGlobalsSlice.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react"
import { renderHook, act } from "@testing-library/react"
import { renderHook } from "@testing-library/react"
import { act } from "react"
import StoreProvider, {
useGlobalsActions,
useGlobalsUrlStateKey,
Expand Down

0 comments on commit 3a755dc

Please sign in to comment.