Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lost backward compatibility about ProjectQuery#results_scope's return type #16

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
APP_PORT=8000
SELENIUM_PORT_1=4444
SELENIUM_PORT_2=5900
MAILCATCHER_PORT=1080
RAILS_DB_ADAPTER=postgresql
POSTGRES_PORT=5433
MYSQL_PORT=3307
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
ARG VARIANT=3.1-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT}

# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
# The value is a comma-separated list of allowed domains
ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev"

# [Choice] Node.js version: lts/*, 16, 14, 12, 10
ARG NODE_VERSION="lts/*"
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends bzr gsfonts imagemagick libmagick++-dev

EXPOSE $APP_PORT
2 changes: 2 additions & 0 deletions .devcontainer/create-db-user.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE USER vscode CREATEDB;
CREATE DATABASE vscode WITH OWNER vscode;
55 changes: 55 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Update the VARIANT arg in docker-compose.yml to pick a Ruby version
{
"name": "Redmine dev mirror",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"rebornix.ruby",
"eamodio.gitlens",
"kaiwood.endwise",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg",
"mtxr.sqltools-driver-mysql",
"ms-vsliveshare.vsliveshare"
],
"settings": {
"workbench.colorCustomizations": {
"activityBar.background": "#ab3e3e"
},
"sqltools.connections": [
{
"previewLimit": 50,
"server": "postgresdb",
"port": 5432,
"driver": "PostgreSQL",
"name": "app_development",
"database": "app_development",
"username": "postgres",
"password": "postgres"
},
{
"previewLimit": 50,
"server": "mysqldb",
"port": 3306,
"driver": "MySQL",
"name": "app_development",
"database": "app_development",
"username": "root",
"password": "password"
},
]
}
}
},
"postCreateCommand": "bash .devcontainer/scripts/postCreateCommand.sh",
"postStartCommand": "bash .devcontainer/scripts/postStartCommand.sh",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
78 changes: 78 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: '3'
services:

# PostgreSQL
postgresdb:
image: postgres:14
restart: on-failure:5
volumes:
- ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- $POSTGRES_PORT:5432

# MySQL
# mysqldb:
# image: mysql:5
# platform: linux/amd64
# restart: on-failure:5
# environment:
# MYSQL_ROOT_PASSWORD: password
# ports:
# - $MYSQL_PORT:3306

app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
APP_PORT: $APP_PORT
# Update 'VARIANT' to pick a version of Ruby: 3, 3.1, 3.0, 2, 2.7, 2.6
# Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: "3.0-bullseye"
# Optional Node.js version to install
NODE_VERSION: "14"
environment:
# PostgreSQL
RAILS_DB_ADAPTER: postgresql
RAILS_DB_HOST: postgresdb
RAILS_DB: app
RAILS_DB_USERNAME: postgres
RAILS_DB_PASSWORD: postgres
RAILS_DB_ENCODING: utf8
RAILS_ENV: development
# # MySQL
# RAILS_DB_ADAPTER: mysql2
# RAILS_DB_HOST: mysqldb
# RAILS_DB: app
# RAILS_DB_USERNAME: root
# RAILS_DB_PASSWORD: password
# RAILS_DB_ENCODING: utf8mb4
# RAILS_ENV: development
env_file: .env
tty: true
ports:
- $APP_PORT:3000
depends_on:
- postgresdb
# - mysqldb
command: sleep infinity
volumes:
- ..:/workspace:cached

# For selenium test
# chrome:
# M1の場合はselenium/standalone-chrome-debugが動かないため、seleniarm/standalone-chromium:latestを代わりに使うこと。
# image: selenium/standalone-chrome-debug:3.141.59-20210913
# ports:
# - $SELENIUM_PORT_1:4444
# - $SELENIUM_PORT_2:5900
# shm_size: 2gb

smtp:
image: schickling/mailcatcher
ports:
- $MAILCATCHER_PORT:1080
17 changes: 17 additions & 0 deletions .devcontainer/files/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server",
"-b",
"0"
]
}
]
}
16 changes: 16 additions & 0 deletions .devcontainer/files/Gemfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
gem 'pry-rails'
gem 'pry-byebug'
gem 'binding_of_caller'
gem 'better_errors'
gem 'view_source_map'
gem 'parallel_tests'
gem 'benchmark-ips'
gem 'activeresource'
gem 'timecop'
if Gem.ruby_version < Gem::Version.new('3.1.0')
gem 'ruby-debug-ide'
gem 'debase', '~> 0.2.5beta2'
end
if Gem.ruby_version >= Gem::Version.new('2.7.0')
gem 'debug'
end
4 changes: 4 additions & 0 deletions .devcontainer/files/additional_environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# redmine-dev-mirror用ファイル

# ログの保存箇所をvolumesの対象外にして同期による負かを軽くする
config.logger = Logger.new('/logs/redmine.log', 2, 1000000)
10 changes: 10 additions & 0 deletions .devcontainer/files/configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# redmine-dev-mirror

development:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: 'smtp'
port: 1025
test:
production:
23 changes: 23 additions & 0 deletions .devcontainer/files/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# redmine-dev-mirror

production:
adapter: <%= ENV['RAILS_DB_ADAPTER'] %>
database: <%= ENV['RAILS_DB'] %>
username: <%= ENV['RAILS_DB_USERNAME'] %>
password: <%= ENV['RAILS_DB_PASSWORD'] %>
host: <%= ENV['RAILS_DB_HOST'] %>
encoding: <%= ENV['RAILS_DB_ENCODING'] %>
development:
adapter: <%= ENV['RAILS_DB_ADAPTER'] %>
database: <%= ENV['RAILS_DB'] %>_development
username: <%= ENV['RAILS_DB_USERNAME'] %>
password: <%= ENV['RAILS_DB_PASSWORD'] %>
host: <%= ENV['RAILS_DB_HOST'] %>
encoding: <%= ENV['RAILS_DB_ENCODING'] %>
test:
adapter: <%= ENV['RAILS_DB_ADAPTER'] %>
database: <%= ENV['RAILS_DB'] %>_test
username: <%= ENV['RAILS_DB_USERNAME'] %>
password: <%= ENV['RAILS_DB_PASSWORD'] %>
host: <%= ENV['RAILS_DB_HOST'] %>
encoding: <%= ENV['RAILS_DB_ENCODING'] %>
15 changes: 15 additions & 0 deletions .devcontainer/scripts/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

cp .devcontainer/files/Gemfile.local Gemfile.local
cp .devcontainer/files/database.yml config/database.yml
cp .devcontainer/files/configuration.yml config/configuration.yml
cp .devcontainer/files/additional_environment.rb config/additional_environment.rb
cp -r .devcontainer/files/.vscode .vscode

sudo mkdir /logs
sudo touch /logs/redmine.log
sudo chown -R vscode /logs

bundle install

rake db:create
9 changes: 9 additions & 0 deletions .devcontainer/scripts/postStartCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

bundle update
rake generate_secret_token

rake db:migrate
rake redmine:plugins:migrate

rake log:clear
16 changes: 4 additions & 12 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
redmine.orgのチケットURL: https://www.redmine.org/issues/xxxx

____________________________________________________________________

Your contributions to Redmine are welcome!

Please **open an issue on the [official website]** instead of sending pull requests.

Since the development of Redmine is not conducted on GitHub but on the [official website] and core developers are not monitoring the GitHub repo, pull requests might not get reviewed.

For more detail about how to contribute, please see the wiki page [Contribute] on the [official website].

[official website]: https://www.redmine.org/
[Contribute]: https://www.redmine.org/projects/redmine/wiki/Contribute
TODO:
- [ ] 単体テストかく
- [ ] ...
76 changes: 76 additions & 0 deletions .github/actions/comment_patch_url.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env ruby

require 'json'

require 'faraday'

REPO = 'agileware-jp/redmine-dev-mirror'

WORKFLOW_RUN = JSON.parse ENV['WORKFLOW_RUN_JSON']

CONNECTION = Faraday.new('https://api.github.com/') do |conn|
conn.response :raise_error
conn.adapter Faraday.default_adapter
end

def repo_resource(resource)
"repos/#{REPO}/#{resource}"
end

def get_repo_resource(resource)
response = CONNECTION.get repo_resource(resource)
JSON.parse response.body
end

def post_to_repo_resource(resource, body)
response = CONNECTION.post repo_resource(resource),
body.to_json,
"Content-Type" => "application/json",
"Authorization" => "token #{ENV['GITHUB_TOKEN']}"
JSON.parse response.body
end

def patch_artifact_id
response = JSON.parse CONNECTION.get(WORKFLOW_RUN['artifacts_url']).body
patch_artifact = response['artifacts'].find { |artifact| artifact['name'] == 'patch' }
patch_artifact['id']
end

def get_suite_id
suite_url = WORKFLOW_RUN['check_suite_url']
id_start_index = suite_url.rindex('/') + 1
suite_url[id_start_index..-1]
end

def patch_artifact_download_url
"https://github.com/#{REPO}/suites/#{get_suite_id}/artifacts/#{patch_artifact_id}"
end

def pull_request_number
WORKFLOW_RUN.dig('pull_requests', 0, 'number')
end

def post_pr_comment(pr_number, comment)
post_to_repo_resource "issues/#{pr_number}/comments", { body: comment }
end

def find_previous_comment_id(pr_number)
comments = get_repo_resource "issues/#{pr_number}/comments"
previous_comment = comments.find { |comment|
comment['body'].include?('Patch can be downloaded [here]') && comment['user']['login'].include?('github-actions')
}
previous_comment['id'] if previous_comment
end

def delete_comment(comment_id)
CONNECTION.delete repo_resource("issues/comments/#{comment_id}"), nil, "Authorization" => "token #{ENV['GITHUB_TOKEN']}"
end

def main
existing_comment_id = find_previous_comment_id(pull_request_number)
delete_comment(existing_comment_id) if existing_comment_id

post_pr_comment pull_request_number, "Patch can be downloaded [here](#{patch_artifact_download_url})" if pull_request_number
end

main if __FILE__ == $0
11 changes: 11 additions & 0 deletions .github/actions/test-with-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -x

database=$1

cp ./config/database.$database.yml ./config/database.yml
bundle install --path vendor/bundle --without minimagick
bundle update
bundle exec rake db:create db:migrate
bundle exec rake test
Loading
Loading