Skip to content

Commit

Permalink
Merge branch 'main' into cuquantum-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Feb 12, 2022
2 parents f816668 + a93a8c8 commit dba674b
Show file tree
Hide file tree
Showing 110 changed files with 4,265 additions and 2,218 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ main ]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [main]
schedule:
- cron: '16 9 * * 6'

Expand All @@ -32,39 +32,39 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'ruby' ]
language: ['javascript', 'ruby']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
*.rb
apps/www/app/assets/builds/
apps/www/db/
apps/www/docs/
dist
docs/_includes/navigation.html
docs/_site/
docs/application.css
docs/application.js
docs/serviceworker.js
examples/elements-example/public/
packages/common/docs/
packages/elements/docs/
packages/simulator/docs/
34 changes: 25 additions & 9 deletions apps/www/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 1. The Qniapp is built as follows:
# $ git clone https://github.com/qniapp/qni.git
# $ cd qni
# $ docker build -f Dockerfile . -t qni_server
# 2. Then run by:
# $ docker run -p 3000:3000 --rm -it qni_server
# 3. access http://127.0.0.1:3000 in your browser

# Troubleshooting
# If the port 3000 is already used, change 3000 to 4000 (for example)
# $ docker run -p 4000:3000 --rm -it qni_server
# and access http://127.0.0.1:4000 in your browser

FROM ubuntu:20.04

RUN apt update
Expand All @@ -11,15 +24,15 @@ RUN echo "${TZ}" > /etc/timezone \
&& ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata


RUN apt install -y build-essential
RUN apt install -y git wget time curl libssl-dev zlib1g-dev libpq-dev
RUN apt install -y redis-server
RUN apt install -y ng-common ng-cjk emacs-nox
RUN apt install -y postgresql postgresql-contrib

## node.js
RUN apt install -y nodejs npm && npm install n -g && n stable && apt purge -y nodejs npm
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
RUN apt-get install -y nodejs

## npm
RUN curl -qL https://www.npmjs.com/install.sh | sh
Expand All @@ -28,14 +41,13 @@ RUN curl -qL https://www.npmjs.com/install.sh | sh
RUN npm install -g yarn

## ruby
RUN wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.3.tar.gz && tar xvfz ruby-2.7.3.tar.gz && cd ruby-2.7.3 && ./configure && make && make install
RUN wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.4.tar.gz && tar xvfz ruby-2.7.4.tar.gz && cd ruby-2.7.4 && ./configure && make && make install

ARG DOCKER_UID=1000
ARG DOCKER_USER=docker
ARG DOCKER_PASSWORD=docker
RUN useradd -u $DOCKER_UID -m $DOCKER_USER --shell /bin/bash && echo "$DOCKER_USER:$DOCKER_PASSWORD" | chpasswd && echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers


USER ${DOCKER_USER}
RUN echo "\n\
[user]\n\
Expand All @@ -49,17 +61,21 @@ RUN cd /home/$DOCKER_USER && echo "cd /home/$DOCKER_USER" >> ~/.bashrc
RUN cd /home/$DOCKER_USER && git clone https://github.com/rbenv/rbenv.git ~/.rbenv
RUN cd /home/$DOCKER_USER && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
RUN cd /home/$DOCKER_USER && echo "export PATH=$PATH:$HOME/.rbenv/bin" >> ~/.bashrc
COPY qni.20210623.tar.gz /home/$DOCKER_USER/
RUN cd /home/$DOCKER_USER && tar xvfz qni.20210623.tar.gz
RUN cd /home/$DOCKER_USER && source ~/.bashrc && cd qni && bundle config set path 'vendor/cache' && bundle install && yarn install
RUN cd /home/$DOCKER_USER && git clone https://github.com/qniapp/qni.git

ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/$DOCKER_USER/.rbenv/bin
RUN cd /home/$DOCKER_USER && cd qni/apps/www && bundle config set path 'vendor/cache' && bundle install && yarn install

## settings for rails
RUN cd /home/$DOCKER_USER && cd qni && yarn build && cd apps/www && ./bin/rails css:build && ./bin/rails javascript:build

## settings for postgresql
RUN sudo -u postgres service postgresql start && sudo -u postgres psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" && sudo -u postgres createdb -O docker docker
RUN cd /home/$DOCKER_USER && sudo -u postgres service postgresql start && source ~/.bashrc && cd qni && ./bin/rails db:create && ./bin/rails db:migrate && ./bin/rails db:fixtures:load
RUN cd /home/$DOCKER_USER && sudo -u postgres service postgresql start && source ~/.bashrc && cd qni/apps/www && ./bin/rails db:create && ./bin/rails db:migrate && ./bin/rails db:fixtures:load

RUN cd /home/$DOCKER_USER && echo -e "#!/usr/bin/env bash\n\
sudo -u postgres service postgresql start \n\
cd /home/${DOCKER_USER} ; source ~/.bashrc ; cd qni \n\
cd /home/${DOCKER_USER} ; source ~/.bashrc ; cd qni/apps/www \n\
./bin/rails s -b 0.0.0.0" > /tmp/startup.sh
RUN chmod 744 /tmp/startup.sh
ENTRYPOINT ["/bin/sh", "-c", "/tmp/startup.sh"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

Welcome to the [Qni](https://qniapp.net) repository. Qni is a quantum computer simulator that runs in your browser.

Qni is largely inspired by Craig Gidney's [Quirk](https://github.com/Strilanc/Quirk), a pioneer in quantum circuit simulators. Qni inherits Quirk's features, such as live programming of quantum circuits and circuit bookmarks, and extends them based on modern web technologies such as CSS responsive design and Web Components standards. This makes it possible to enjoy quantum circuit programming on smartphones and embed "live" quantum circuits in any web page.

## Contents

This repository is a monorepo containing three packages:

- [**packages/common**](https://github.com/qniapp/qni/tree/main/packages/common) contains the source for the [@qni/common](https://www.npmjs.com/package/@qni/common) package. This is a common library used by other Qni packages.
- [**packages/simulator**](https://github.com/qniapp/qni/tree/main/packages/simulator) contains the source for the [@qni/simulator](https://www.npmjs.com/package/@qni/simulator) package. This is a quantum computer simulator implementation in TypeScript. It is usually called by the browser's ServiceWorker thread and runs asynchronously.
- [**packages/elements**](https://github.com/qniapp/qni/tree/main/packages/elements) contains the source for the [@qni/elements](https://www.npmjs.com/package/@qni/elements) package. This is a custom Web component library for rendering quantum circuits. It is used by `@qni/www` as well as several other projects.
- [**packages/elements**](https://github.com/qniapp/qni/tree/main/packages/elements) contains the source for the [@qni/elements](https://www.npmjs.com/package/@qni/elements) package. This is a custom web component library for rendering quantum circuits. It is used by `@qni/www` as well as several other projects.

And one app:

Expand Down
6 changes: 1 addition & 5 deletions apps/www/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": [
"plugin:github/recommended",
"plugin:github/browser",
"plugin:github/typescript"
],
"extends": ["plugin:github/recommended", "plugin:github/browser", "plugin:github/typescript", "prettier"],
"rules": {
"i18n-text/no-en": "off",
"import/named": "off"
Expand Down
6 changes: 3 additions & 3 deletions apps/www/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ AllCops:
TargetRailsVersion: 6.0
NewCops: enable
Exclude:
- "bin/*"
- "db/**/*"
- "tmp/**/*"
- 'bin/*'
- 'db/**/*'
- 'tmp/**/*'

# Lint
Lint/MissingSuper:
Expand Down
2 changes: 1 addition & 1 deletion apps/www/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gem 'view_component', require: 'view_component/engine'
# Drivers
gem 'pg'

gem 'puma', '~> 5.5'
gem 'puma', '~> 5.6'

# JavaScript, CSS and assets
gem 'cssbundling-rails'
Expand Down
4 changes: 2 additions & 2 deletions apps/www/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ GEM
ast (~> 2.4.1)
pg (1.2.3)
public_suffix (4.0.6)
puma (5.5.2)
puma (5.6.2)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
Expand Down Expand Up @@ -296,7 +296,7 @@ DEPENDENCIES
jsbundling-rails
listen (>= 3.0.5, < 3.2)
pg
puma (~> 5.5)
puma (~> 5.6)
rack-mini-profiler
rails (~> 6.1)
rbtrace
Expand Down
8 changes: 3 additions & 5 deletions apps/www/app/assets/javascripts/serviceworker-companion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
if (navigator.serviceWorker) {
navigator.serviceWorker
.register("/serviceworker.js", { scope: "./" })
.catch(function (error) {
console.log("[Companion]", "Service worker registration failed: " + error)
})
navigator.serviceWorker.register('/serviceworker.js', {scope: './'}).catch(function (error) {
console.log('[Companion]', 'Service worker registration failed: ' + error)
})
}
2 changes: 1 addition & 1 deletion apps/www/app/assets/stylesheets/gate_popup.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.gate-popup {
&__input-wrapper {
@apply border-2 border-swan;
@apply border-swan border-2;
@apply px-3 py-2;
@apply relative;
@apply rounded-md;
Expand Down
6 changes: 3 additions & 3 deletions apps/www/app/assets/stylesheets/quantum_simulator.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
quantum-simulator {
.circle-notation[data-nqubit="8"],
.circle-notation[data-nqubit="9"],
.circle-notation[data-nqubit="10"] {
.circle-notation[data-nqubit='8'],
.circle-notation[data-nqubit='9'],
.circle-notation[data-nqubit='10'] {
@apply md:overflow-y-scroll;
@apply md:h-40;
}
Expand Down
22 changes: 11 additions & 11 deletions apps/www/app/assets/stylesheets/tippy.css
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
@import "tippy.js/dist/border.css";
@import "tippy.js/dist/svg-arrow.css";
@import "tippy.js/dist/tippy.css";
@import 'tippy.js/dist/border.css';
@import 'tippy.js/dist/svg-arrow.css';
@import 'tippy.js/dist/tippy.css';

.tippy-box[data-theme~="qni"] {
.tippy-box[data-theme~='qni'] {
@apply bg-snow;
@apply border-2 border-solid border-eel;
@apply border-eel border-2 border-solid;
@apply text-wolf;
@apply text-xs;
@apply md:text-sm;

/* The border */
.tippy-svg-arrow > svg:first-child {
fill: theme("colors.eel");
fill: theme('colors.eel');
}

/* The fill */
.tippy-svg-arrow > svg:last-child {
fill: theme("colors.snow");
fill: theme('colors.snow');
}

&[data-placement^="top"] > .tippy-svg-arrow svg:first-child {
&[data-placement^='top'] > .tippy-svg-arrow svg:first-child {
top: 18px;
}

&[data-placement^="bottom"] > .tippy-svg-arrow svg:first-child {
&[data-placement^='bottom'] > .tippy-svg-arrow svg:first-child {
bottom: 18px;
}

&[data-placement^="left"] > .tippy-svg-arrow svg:first-child {
&[data-placement^='left'] > .tippy-svg-arrow svg:first-child {
left: 13px;
}

&[data-placement^="right"] > .tippy-svg-arrow svg:first-child {
&[data-placement^='right'] > .tippy-svg-arrow svg:first-child {
right: 13px;
}

Expand Down
Loading

0 comments on commit dba674b

Please sign in to comment.