Skip to content

Commit a4f42e9

Browse files
ruby on rails
0 parents  commit a4f42e9

File tree

4,437 files changed

+574337
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,437 files changed

+574337
-0
lines changed

.devcontainer/Dockerfile

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6
4+
ARG VARIANT="3.0"
5+
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
6+
7+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
COPY .devcontainer/library-scripts/github-debian.sh /tmp/library-scripts/
12+
RUN apt-get update && bash /tmp/library-scripts/github-debian.sh
13+
14+
# [Optional] Uncomment this section to install additional OS packages.
15+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
16+
&& apt-get -y install --no-install-recommends \
17+
mariadb-server libmariadb-dev \
18+
postgresql postgresql-client postgresql-contrib libpq-dev \
19+
redis-server memcached \
20+
ffmpeg mupdf mupdf-tools libvips poppler-utils
21+
22+
23+
ARG IMAGEMAGICK_VERSION="7.1.0-5"
24+
RUN wget -qO /tmp/im.tar.xz https://imagemagick.org/archive/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz \
25+
&& wget -qO /tmp/im.sig https://imagemagick.org/archive/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz.asc \
26+
&& gpg --batch --keyserver keyserver.ubuntu.com --recv 89AB63D48277377A \
27+
&& gpg --batch --verify /tmp/im.sig /tmp/im.tar.xz \
28+
&& tar xJf /tmp/im.tar.xz -C /tmp \
29+
&& cd /tmp/ImageMagick-$IMAGEMAGICK_VERSION \
30+
&& ./configure --with-rsvg && make -j 9 && make install \
31+
&& ldconfig /usr/local/lib \
32+
&& rm -rf /tmp/*
33+
34+
# Add the Rails main Gemfile and install the gems. This means the gem install can be done
35+
# during build instead of on start. When a fork or branch has different gems, we still have an
36+
# advantage due to caching of the other gems.
37+
RUN mkdir -p /tmp/rails
38+
COPY Gemfile Gemfile.lock RAILS_VERSION rails.gemspec package.json yarn.lock /tmp/rails/
39+
COPY actioncable/actioncable.gemspec /tmp/rails/actioncable/
40+
COPY actionmailbox/actionmailbox.gemspec /tmp/rails/actionmailbox/
41+
COPY actionmailer/actionmailer.gemspec /tmp/rails/actionmailer/
42+
COPY actionpack/actionpack.gemspec /tmp/rails/actionpack/
43+
COPY actiontext/actiontext.gemspec /tmp/rails/actiontext/
44+
COPY actionview/actionview.gemspec /tmp/rails/actionview/
45+
COPY activejob/activejob.gemspec /tmp/rails/activejob/
46+
COPY activemodel/activemodel.gemspec /tmp/rails/activemodel/
47+
COPY activerecord/activerecord.gemspec /tmp/rails/activerecord/
48+
COPY activestorage/activestorage.gemspec /tmp/rails/activestorage/
49+
COPY activesupport/activesupport.gemspec /tmp/rails/activesupport/
50+
COPY railties/railties.gemspec /tmp/rails/railties/
51+
RUN cd /tmp/rails \
52+
&& bundle install \
53+
&& yarn install \
54+
&& rm -rf /tmp/rails

.devcontainer/boot.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
bundle install
2+
yarn install
3+
4+
sudo chown -R vscode:vscode /usr/local/bundle
5+
6+
sudo service postgresql start
7+
sudo service mariadb start
8+
sudo service redis-server start
9+
sudo service memcached start
10+
11+
# Create PostgreSQL users and databases
12+
sudo su postgres -c "createuser --superuser vscode"
13+
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest"
14+
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest2"
15+
16+
# Create MySQL database and databases
17+
cd activerecord
18+
MYSQL_CODESPACES=1 bundle exec rake db:mysql:build

.devcontainer/devcontainer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby
3+
{
4+
"name": "Ruby",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": "..",
8+
"args": {
9+
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
10+
"VARIANT": "3",
11+
// Options
12+
"NODE_VERSION": "lts/*"
13+
}
14+
},
15+
16+
// Set *default* container specific settings.json values on container create.
17+
"settings": {},
18+
19+
// Add the IDs of extensions you want installed when the container is created.
20+
"extensions": [
21+
"rebornix.Ruby"
22+
],
23+
24+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25+
// "forwardPorts": [],
26+
27+
// Use 'postCreateCommand' to run commands after the container is created.
28+
"postCreateCommand": ".devcontainer/boot.sh",
29+
30+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
31+
"remoteUser": "vscode"
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
#!/usr/bin/env bash
2+
#-------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+
#-------------------------------------------------------------------------------------------------------------
6+
#
7+
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/github.md
8+
# Maintainer: The VS Code and Codespaces Teams
9+
#
10+
# Syntax: ./github-debian.sh [version]
11+
12+
CLI_VERSION=${1:-"latest"}
13+
14+
GITHUB_CLI_ARCHIVE_GPG_KEY=C99B11DEB97541F0
15+
GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80
16+
keyserver hkps://keys.openpgp.org
17+
keyserver hkp://keyserver.pgp.com"
18+
19+
set -e
20+
21+
if [ "$(id -u)" -ne 0 ]; then
22+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
23+
exit 1
24+
fi
25+
26+
# Get central common setting
27+
get_common_setting() {
28+
if [ "${common_settings_file_loaded}" != "true" ]; then
29+
curl -sfL "https://aka.ms/vscode-dev-containers/script-library/settings.env" 2>/dev/null -o /tmp/vsdc-settings.env || echo "Could not download settings file. Skipping."
30+
common_settings_file_loaded=true
31+
fi
32+
if [ -f "/tmp/vsdc-settings.env" ]; then
33+
local multi_line=""
34+
if [ "$2" = "true" ]; then multi_line="-z"; fi
35+
local result="$(grep ${multi_line} -oP "$1=\"?\K[^\"]+" /tmp/vsdc-settings.env | tr -d '\0')"
36+
if [ ! -z "${result}" ]; then declare -g $1="${result}"; fi
37+
fi
38+
echo "$1=${!1}"
39+
}
40+
41+
# Import the specified key in a variable name passed in as
42+
receive_gpg_keys() {
43+
get_common_setting $1
44+
local keys=${!1}
45+
get_common_setting GPG_KEY_SERVERS true
46+
47+
# Use a temporary location for gpg keys to avoid polluting image
48+
export GNUPGHOME="/tmp/tmp-gnupg"
49+
mkdir -p ${GNUPGHOME}
50+
chmod 700 ${GNUPGHOME}
51+
echo -e "disable-ipv6\n${GPG_KEY_SERVERS}" > ${GNUPGHOME}/dirmngr.conf
52+
# GPG key download sometimes fails for some reason and retrying fixes it.
53+
local retry_count=0
54+
local gpg_ok="false"
55+
set +e
56+
until [ "${gpg_ok}" = "true" ] || [ "${retry_count}" -eq "5" ];
57+
do
58+
echo "(*) Downloading GPG key..."
59+
( echo "${keys}" | xargs -n 1 gpg --recv-keys) 2>&1 && gpg_ok="true"
60+
if [ "${gpg_ok}" != "true" ]; then
61+
echo "(*) Failed getting key, retring in 10s..."
62+
(( retry_count++ ))
63+
sleep 10s
64+
fi
65+
done
66+
set -e
67+
if [ "${gpg_ok}" = "false" ]; then
68+
echo "(!) Failed to get gpg key."
69+
exit 1
70+
fi
71+
}
72+
73+
# Figure out correct version of a three part version number is not passed
74+
find_version_from_git_tags() {
75+
local variable_name=$1
76+
local requested_version=${!variable_name}
77+
if [ "${requested_version}" = "none" ]; then return; fi
78+
local repository=$2
79+
local prefix=${3:-"tags/v"}
80+
local separator=${4:-"."}
81+
local last_part_optional=${5:-"false"}
82+
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
83+
local escaped_separator=${separator//./\\.}
84+
local last_part
85+
if [ "${last_part_optional}" = "true" ]; then
86+
last_part="(${escaped_separator}[0-9]+)?"
87+
else
88+
last_part="${escaped_separator}[0-9]+"
89+
fi
90+
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
91+
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
92+
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
93+
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
94+
else
95+
set +e
96+
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
97+
set -e
98+
fi
99+
fi
100+
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then
101+
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
102+
exit 1
103+
fi
104+
echo "${variable_name}=${!variable_name}"
105+
}
106+
107+
# Import the specified key in a variable name passed in as
108+
receive_gpg_keys() {
109+
get_common_setting $1
110+
local keys=${!1}
111+
get_common_setting GPG_KEY_SERVERS true
112+
local keyring_args=""
113+
if [ ! -z "$2" ]; then
114+
keyring_args="--no-default-keyring --keyring $2"
115+
fi
116+
117+
# Use a temporary location for gpg keys to avoid polluting image
118+
export GNUPGHOME="/tmp/tmp-gnupg"
119+
mkdir -p ${GNUPGHOME}
120+
chmod 700 ${GNUPGHOME}
121+
echo -e "disable-ipv6\n${GPG_KEY_SERVERS}" > ${GNUPGHOME}/dirmngr.conf
122+
# GPG key download sometimes fails for some reason and retrying fixes it.
123+
local retry_count=0
124+
local gpg_ok="false"
125+
set +e
126+
until [ "${gpg_ok}" = "true" ] || [ "${retry_count}" -eq "5" ];
127+
do
128+
echo "(*) Downloading GPG key..."
129+
( echo "${keys}" | xargs -n 1 gpg -q ${keyring_args} --recv-keys) 2>&1 && gpg_ok="true"
130+
if [ "${gpg_ok}" != "true" ]; then
131+
echo "(*) Failed getting key, retring in 10s..."
132+
(( retry_count++ ))
133+
sleep 10s
134+
fi
135+
done
136+
set -e
137+
if [ "${gpg_ok}" = "false" ]; then
138+
echo "(!) Failed to get gpg key."
139+
exit 1
140+
fi
141+
}
142+
143+
# Function to run apt-get if needed
144+
apt_get_update_if_needed()
145+
{
146+
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
147+
echo "Running apt-get update..."
148+
apt-get update
149+
else
150+
echo "Skipping apt-get update."
151+
fi
152+
}
153+
154+
# Checks if packages are installed and installs them if not
155+
check_packages() {
156+
if ! dpkg -s "$@" > /dev/null 2>&1; then
157+
apt_get_update_if_needed
158+
apt-get -y install --no-install-recommends "$@"
159+
fi
160+
}
161+
162+
export DEBIAN_FRONTEND=noninteractive
163+
164+
# Install curl, apt-transport-https, curl, gpg, or dirmngr, git if missing
165+
check_packages curl ca-certificates apt-transport-https dirmngr gnupg2
166+
if ! type git > /dev/null 2>&1; then
167+
apt_get_update_if_needed
168+
apt-get -y install --no-install-recommends git
169+
fi
170+
171+
# Soft version matching
172+
if [ "${CLI_VERSION}" != "latest" ] && [ "${CLI_VERSION}" != "lts" ] && [ "${CLI_VERSION}" != "stable" ]; then
173+
find_version_from_git_tags CLI_VERSION "https://github.com/cli/cli"
174+
version_suffix="=${CLI_VERSION}"
175+
else
176+
version_suffix=""
177+
fi
178+
179+
# Install the GitHub CLI
180+
echo "Downloading GitHub CLI..."
181+
# Import key safely (new method rather than deprecated apt-key approach) and install
182+
. /etc/os-release
183+
receive_gpg_keys GITHUB_CLI_ARCHIVE_GPG_KEY /usr/share/keyrings/githubcli-archive-keyring.gpg
184+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/github-cli.list
185+
apt-get update
186+
apt-get -y install "gh${version_suffix}"
187+
rm -rf "/tmp/gh/gnupg"
188+
echo "Done!"

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.rb diff=ruby
2+
*.gemspec diff=ruby

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.rubocop.yml @rafaelfranca

.github/autolabeler.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
actioncable:
2+
- "actioncable/**/*"
3+
actionmailbox:
4+
- "actionmailbox/**/*"
5+
actionmailer:
6+
- "actionmailer/**/*"
7+
actionpack:
8+
- "actionpack/**/*"
9+
actiontext:
10+
- "actiontext/**/*"
11+
actionview:
12+
- "actionview/**/*"
13+
activejob:
14+
- "activejob/**/*"
15+
activemodel:
16+
- "activemodel/**/*"
17+
activerecord:
18+
- "activerecord/**/*"
19+
activestorage:
20+
- "activestorage/**/*"
21+
activesupport:
22+
- "activesupport/**/*"
23+
rails-ujs:
24+
- "actionview/app/assets/javascripts/rails-ujs*/*"
25+
railties:
26+
- "railties/**/*"
27+
docs:
28+
- "guides/**/*"

.github/issue_template.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Steps to reproduce
2+
<!-- (Guidelines for creating a bug report are [available
3+
here](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#creating-a-bug-report)) -->
4+
5+
<!-- Paste your executable test case created from one of the scripts found [here](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#create-an-executable-test-case) below: -->
6+
```ruby
7+
# Your reproduction script goes here
8+
```
9+
10+
### Expected behavior
11+
<!-- Tell us what should happen -->
12+
13+
### Actual behavior
14+
<!-- Tell us what happens instead -->
15+
16+
### System configuration
17+
**Rails version**:
18+
19+
**Ruby version**:

.github/no-response.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Configuration for probot-no-response - https://github.com/probot/no-response
2+
3+
# Number of days of inactivity before an Issue is closed for lack of response
4+
daysUntilClose: 14
5+
# Label requiring a response
6+
responseRequiredLabel: more-information-needed
7+
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
8+
closeComment: >
9+
This issue has been automatically closed because there has been no follow-up
10+
response from the original author. We currently don't have enough
11+
information in order to take action. Please reach out if you have any additional
12+
information that will help us move this issue forward.

.github/pull_request_template.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### Summary
2+
3+
<!-- Provide a general description of the code changes in your pull
4+
request... were there any bugs you had fixed? If so, mention them. If
5+
these bugs have open GitHub issues, be sure to tag them here as well,
6+
to keep the conversation linked together. -->
7+
8+
### Other Information
9+
10+
<!-- If there's anything else that's important and relevant to your pull
11+
request, mention that information here. This could include
12+
benchmarks, or other information.
13+
14+
If you are updating any of the CHANGELOG files or are asked to update the
15+
CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.
16+
17+
Finally, if your pull request affects documentation or any non-code
18+
changes, guidelines for those changes are [available
19+
here](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation)
20+
21+
Thanks for contributing to Rails! -->
22+
23+
<!--
24+
Note: Please avoid making *Draft* pull requests, as they still send
25+
notifications to everyone watching the Rails repo.
26+
Create a pull request when it is ready for review and feedback
27+
from the Rails team :).
28+
-->

0 commit comments

Comments
 (0)