Skip to content

Commit

Permalink
Merge pull request #35 from ProvideQ/release/0.3.0
Browse files Browse the repository at this point in the history
Release version 0.3.0
  • Loading branch information
Elscrux authored Sep 28, 2023
2 parents c0e8f40 + 5eaec18 commit 802fd36
Show file tree
Hide file tree
Showing 50 changed files with 4,288 additions and 3,681 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/ci-cd-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# adapted from https://github.com/dokku/github-action/blob/db5e3b84461e5e73c56d8b0f6a67aab0df25256c/example-workflows/simple.yml
name: "CI/CD"

on:
push:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Clone repo (shallow)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn install
- name: Run linter
run: yarn lint
test:
runs-on: ubuntu-latest
steps:
- name: Clone repo (shallow)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn test
build:
runs-on: ubuntu-latest
steps:
- name: Clone repo (shallow)
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn build
deploy:
runs-on: ubuntu-latest
needs:
- lint
- test
- build
if: ${{ github.ref == 'refs/heads/develop' }}
steps:
- name: Cloning repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Push to dokku
uses: dokku/github-action@master
with:
branch: develop
# only extracting the server address to a secret avoids leaking it in the logs
git_remote_url: ssh://dokku@${{ secrets.DOKKU_SERVER_ADDRESS }}/toolbox-frontend-staging
ssh_private_key: ${{ secrets.DOKKU_DEPLOYMENT_KEY }}
24 changes: 0 additions & 24 deletions .github/workflows/deploy-develop.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# adapted from https://github.com/dokku/github-action/blob/db5e3b84461e5e73c56d8b0f6a67aab0df25256c/example-workflows/simple.yml
name: 'deploy-main'
name: "deploy-main"

on:
push:
Expand Down
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# compiled app
.next/
next-env.d.ts

# dependencies
node_modules/
yarn.lock

# static assets
public/
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 ProvideQ
Copyright (c) 2022 - 2023 ProvideQ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[![Build](https://img.shields.io/github/actions/workflow/status/ProvideQ/toolbox-web/deploy-main.yml?style=for-the-badge)](https://github.com/ProvideQ/toolbox-web/actions/workflows/deploy-main.yml)
[![Release](https://img.shields.io/github/v/release/ProvideQ/toolbox-web?style=for-the-badge)](https://github.com/ProvideQ/toolbox-web/releases/)

# ProvideQ
This repository contains the web frontend for the ProvideQ toolbox.

This repository contains the web frontend for the ProvideQ toolbox.

## Development setup

1. Install [Node.js 16](https://nodejs.org/) (check with `node -v`)
2. Make sure that the [Yarn package manager is enabled](https://yarnpkg.com/getting-started/install) (check with `yarn -v`)
3. Clone this repository
Expand All @@ -10,9 +15,28 @@ This repository contains the web frontend for the ProvideQ toolbox.
By default, Next.js will collect
[anonymous telemetry data](https://nextjs.org/telemetry).
You can disable the data collection using `yarn exec next telemetry disable`.
5. Use `yarn dev` to spin up a local development server
6. Use `yarn dev` to spin up a local development server

## Releasing a new version

1. Create a release branch from develop: `git checkout -b release/x.y.z`.
2. Bump the version number in the `package.json` file to the new version number
and commit it to the release branch.
3. Push to GitHub and create a pull request to merge the release branch into
`main`.
4. Make sure to test your new version!
5. Write a changelog.
The PR can help you identify differences between the last release (`main`)
and the next one (your release branch).
6. Merge the PR into main.
7. [Create a new GitHub release](https://github.com/ProvideQ/toolbox-web/releases/new) with a new tag named like your
version number `x.y.z` and use the changelog as the description.
8. Pull the main branch (`git checkout main && git pull`), merge it into the
develop branch (`git checkout develop && git pull && git merge main`) and
push it (`git push`).

## License
Copyright (c) 2022 ProvideQ

Copyright (c) 2022 - 2023 ProvideQ

This project is available under the [MIT License](./LICENSE)
169 changes: 88 additions & 81 deletions __tests__/converter/dimacs/DimacsLogicalExpression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,99 @@ import { LogicalExpressionParser } from "../../../src/converter/dimacs/LogicalEx
import { regexNOT } from "../../../src/converter/dimacs/Syntax/LogicalExpressionSyntax";

function isEquivalentLogicalExpression(f1: string, f2: string) {
expect(f1.replace(regexNOT, '!')
.replace(regexBlank, ''))
.toBe(f2.replace(regexNOT, '!')
.replace(regexBlank, ''));
expect(f1.replace(regexNOT, "!").replace(regexBlank, "")).toBe(
f2.replace(regexNOT, "!").replace(regexBlank, "")
);
}

function isEquivalentDimacs(f1: string, f2: string) {
expect(f1.replace(regexComment, '')
.replace(regexBlank, ''))
.toBe(f2.replace(regexComment, '')
.replace(regexBlank, ''));
expect(f1.replace(regexComment, "").replace(regexBlank, "")).toBe(
f2.replace(regexComment, "").replace(regexBlank, "")
);
}

describe("Parsing", () => {
let dimacsParser = new DimacsParser();
let logicalExpressionParser = new LogicalExpressionParser();
let dimacsParser = new DimacsParser();
let logicalExpressionParser = new LogicalExpressionParser();

each([
[
'((1 or 2 or not 3) and (!4 and (not 5 and 6)) and 3 and (7 or 2))',
'c First comment\nc Some Comment\nc 1 => 1\np sat 7\n*(+( 1 2 -3 )*( -4 *( -5 6 )) 3 +( 7 2 ))'
],
[
'(1 or (2 and 3) or (((1 and 4) or 5) and 6))',
'p sat 6\n+(1 *(2 3)*(+(*(1 4) 5) 6))'
],
[
'(((1 and not 2 and 3 and 4) or 3) and 5)',
'c Sample DIMACS .sat file\np sat 5\n*(+(*(1 -2 3 4) 3) 5)'
],
[
'((1 and not 2) or 3)',
'p sat 3\n+(*(1 -2) 3)'
],
[
'((1 and 2) or not 3)',
'p sat 3\n+(*(1 2) -3)'
]
]).test("parsing bi-directional", (logicalExpression: string, dimacs: string) => {
isEquivalentDimacs(logicalExpressionParser.parseDimacs(logicalExpression), dimacs);
isEquivalentLogicalExpression(dimacsParser.parseLogicalExpression(dimacs), logicalExpression);
});
each([
[
"((1 or 2 or not 3) and (!4 and (not 5 and 6)) and 3 and (7 or 2))",
"c First comment\nc Some Comment\nc 1 => 1\np sat 7\n*(+( 1 2 -3 )*( -4 *( -5 6 )) 3 +( 7 2 ))",
],
[
"(1 or (2 and 3) or (((1 and 4) or 5) and 6))",
"p sat 6\n+(1 *(2 3)*(+(*(1 4) 5) 6))",
],
[
"(((1 and not 2 and 3 and 4) or 3) and 5)",
"c Sample DIMACS .sat file\np sat 5\n*(+(*(1 -2 3 4) 3) 5)",
],
["((1 and not 2) or 3)", "p sat 3\n+(*(1 -2) 3)"],
["((1 and 2) or not 3)", "p sat 3\n+(*(1 2) -3)"],
]).test(
"parsing bi-directional",
(logicalExpression: string, dimacs: string) => {
isEquivalentDimacs(
logicalExpressionParser.parseDimacs(logicalExpression),
dimacs
);
isEquivalentLogicalExpression(
dimacsParser.parseLogicalExpression(dimacs),
logicalExpression
);
}
);

each([
[
'((a or b or not c) and (not x and (not y and z)) and c and (d or c))',
'c 1 => a\n' +
'c 2 => b\n' +
'c 3 => c\n' +
'c 4 => x\n' +
'c 5 => y\n' +
'c 6 => z\n' +
'c 7 => d\n' +
'p sat 7\n' +
'*(+(1 2 -3) *(-4 *(-5 6)) 3 +(7 3))'
],
[
'(c or (a and b) or (((c and d) or e ) and f))',
'c 1 => c\n' +
'c 2 => a\n' +
'c 3 => b\n' +
'c 4 => d\n' +
'c 5 => e\n' +
'c 6 => f\n' +
'p sat 6\n' +
'+(1 *(2 3)*(+(*(1 4) 5) 6))'
],
[
'(((a and not d and c and b) or c) and e)',
'c 1 => a\n' +
'c 2 => d\n' +
'c 3 => c\n' +
'c 4 => b\n' +
'c 5 => e\n' +
'p sat 5\n' +
'*(+(*(1 -2 3 4) 3) 5)'
],
[
'((a and not b) or c)',
'c 1 => a\n' +
'c 2 => b\n' +
'c 3 => c\n' +
'p sat 3\n' +
'+(*(1 -2) 3)'
]
]).test("parsing dimacs with variable aliases", (logicalExpression: string, dimacs: string) => {
isEquivalentLogicalExpression(dimacsParser.parseLogicalExpression(dimacs), logicalExpression);
});
});
each([
[
"((a or b or not c) and (not x and (not y and z)) and c and (d or c))",
"c 1 => a\n" +
"c 2 => b\n" +
"c 3 => c\n" +
"c 4 => x\n" +
"c 5 => y\n" +
"c 6 => z\n" +
"c 7 => d\n" +
"p sat 7\n" +
"*(+(1 2 -3) *(-4 *(-5 6)) 3 +(7 3))",
],
[
"(c or (a and b) or (((c and d) or e ) and f))",
"c 1 => c\n" +
"c 2 => a\n" +
"c 3 => b\n" +
"c 4 => d\n" +
"c 5 => e\n" +
"c 6 => f\n" +
"p sat 6\n" +
"+(1 *(2 3)*(+(*(1 4) 5) 6))",
],
[
"(((a and not d and c and b) or c) and e)",
"c 1 => a\n" +
"c 2 => d\n" +
"c 3 => c\n" +
"c 4 => b\n" +
"c 5 => e\n" +
"p sat 5\n" +
"*(+(*(1 -2 3 4) 3) 5)",
],
[
"((a and not b) or c)",
"c 1 => a\n" +
"c 2 => b\n" +
"c 3 => c\n" +
"p sat 3\n" +
"+(*(1 -2) 3)",
],
]).test(
"parsing dimacs with variable aliases",
(logicalExpression: string, dimacs: string) => {
isEquivalentLogicalExpression(
dimacsParser.parseLogicalExpression(dimacs),
logicalExpression
);
}
);
});
22 changes: 11 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// jest.config.js
const nextJest = require('next/jest')
const nextJest = require("next/jest");

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});

// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const customJestConfig = {
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
}
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ["node_modules", "<rootDir>/"],
testEnvironment: "jest-environment-jsdom",
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
module.exports = createJestConfig(customJestConfig);
6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true
}
swcMinify: true,
};

module.exports = nextConfig
module.exports = nextConfig;
Loading

0 comments on commit 802fd36

Please sign in to comment.