Skip to content

Commit

Permalink
Merge branch 'master' into setup-downloads-on-timescaledb
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatas authored Nov 18, 2024
2 parents 718c6a4 + a07d05c commit 12115bd
Show file tree
Hide file tree
Showing 552 changed files with 11,515 additions and 4,586 deletions.
35 changes: 5 additions & 30 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
# syntax = docker/dockerfile:1.4

ARG RUBY_VERSION=3.3
ARG RUBY_VERSION=3.3.5
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

FROM ruby:${RUBY_VERSION}-alpine

ENV USERNAME=vscode \
UID=1000 \
GID=1000

# Install the git-credential-manager package via the dotnet tooling to
RUN apk update && apk add --no-cache \
github-cli \
git \
build-base \
bash \
mandoc \
man-pages \
tzdata \
libpq-dev \
libmagic \
nodejs \
sudo

# create non-root group and user
RUN addgroup -g $GID $USERNAME \
&& adduser -s /bin/bash -u $UID -G $USERNAME $USERNAME --disabled-password --gecos ""

# set sudo permissions for vscode user
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
RUN chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends pkg-config \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
17 changes: 14 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"docker-compose.yml",
"../docker-compose.yml"
],
"service": "app",
"service": "rails-app",
"runServices": [
"db",
"cache",
"search",
"toxiproxy"
"toxiproxy",
"selenium"
],
"forwardPorts": [
3000, // Rails
Expand All @@ -23,10 +24,20 @@
"onCreateCommand": "bin/setup",
// Use 'updateContentCommand' to run commands when the container is updated.
"updateContentCommand": "bin/setup",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
// "ghcr.io/rails/devcontainer/features/activestorage": {},
"ghcr.io/rails/devcontainer/features/postgres-client": {}
},
// Configure tool-specific properties.
"containerEnv": {
"EDITOR": "code --wait",
"GIT_EDITOR": "code --wait"
"GIT_EDITOR": "code --wait",
"CAPYBARA_SERVER_PORT": "45678",
"SELENIUM_HOST": "selenium",
"ELASTICSEARCH_URL": "http://search:9200",
"DATABASE_URL": "postgres://postgres@db:5432"
},
"customizations": {
"codespaces": {
Expand Down
16 changes: 10 additions & 6 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
version: "3"
services:
app:
rails-app:
build:
context: .
dockerfile: Dockerfile
command: /bin/sh -c "while sleep 1000; do :; done"
command: sleep infinity
volumes:
- ../..:/workspaces:cached
environment:
- ELASTICSEARCH_URL=http://search:9200
- DATABASE_URL=postgres://postgres@db:5432
depends_on:
- search
- db
- selenium

selenium:
image: selenium/standalone-chromium
restart: unless-stopped
11 changes: 10 additions & 1 deletion .github/actions/setup-rubygems.org/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@ inputs:
rubygems-version:
description: "RubyGems version to use"
required: true
install-avo-pro:
description: "Install Avo gem"
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Install and start services
shell: bash
run: |
docker compose up -d --wait
- uses: ruby/setup-ruby@3783f195e29b74ae398d7caca108814bbafde90e # v1.180.1
- name: Configure bundler environment
shell: bash
if: github.secret_source != 'None' && inputs.install-avo-pro == 'true'
run: |
printf "BUNDLE_WITH=avo\nRAILS_GROUPS=avo\n" >> $GITHUB_ENV
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # v1.191.0
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ permissions: # added using https://github.com/step-security/secure-workflows
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
Expand All @@ -41,11 +41,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -58,7 +58,7 @@ jobs:
# 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@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
uses: github/codeql-action/autobuild@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -71,6 +71,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
category: "/language:${{matrix.language}}"
16 changes: 9 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ permissions:
jobs:
build:
name: Docker build (and optional push)
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
env:
RUBYGEMS_VERSION: 3.5.14
RUBY_VERSION: 3.3.3
RUBYGEMS_VERSION: "3.5.20"
RUBY_VERSION: "3.3.5"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # master
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # master
- name: Cache Docker layers
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-rubygems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-rubygems-org
- name: Install and start services (needed for image test)
run: docker-compose up -d
run: docker compose up -d
- name: Configure AWS credentials from Production account
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
if: github.secret_source != 'None'
Expand All @@ -41,6 +41,8 @@ jobs:
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: build, test and optionally push docker image
run: ./script/build_docker.sh
env:
BUNDLE_PACKAGER__DEV: ${{ secrets.BUNDLE_PACKAGER__DEV }}
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
Expand Down
43 changes: 29 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ permissions:
jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ruby/setup-ruby@97e35c5302afcf3f5ac1df3fca9343d32536b286 # v1.184.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
with:
bundler-cache: true
- name: Rubocop
run: bundle exec rubocop
brakeman:
name: Brakeman
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ruby/setup-ruby@97e35c5302afcf3f5ac1df3fca9343d32536b286 # v1.184.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
with:
bundler-cache: true
- name: Brakeman
run: bundle exec brakeman
importmap:
name: Importmap Verify
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ruby/setup-ruby@97e35c5302afcf3f5ac1df3fca9343d32536b286 # v1.184.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
with:
bundler-cache: true
- name: Importmap Verify
run: bundle exec rake importmap:verify
kubeconform:
name: Kubeconform
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
kubernetes_version: ["1.29.1"]
Expand All @@ -50,8 +50,8 @@ jobs:
steps:
- name: login to Github Packages
run: echo "${{ github.token }}" | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ruby/setup-ruby@97e35c5302afcf3f5ac1df3fca9343d32536b286 # v1.184.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
with:
bundler-cache: true
- name: krane render
Expand All @@ -60,12 +60,27 @@ jobs:
env:
ENVIRONMENT: "${{ matrix.environment }}"
REVISION: "${{ github.sha }}"
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: "${{ matrix.environment }}.rendered.yaml"
path: "config/deploy/${{ matrix.environment }}.rendered.yaml"
- name: kubeconform
uses: docker://ghcr.io/yannh/kubeconform:v0.6.3
uses: docker://ghcr.io/yannh/kubeconform@sha256:03f6b236ef64f20b4bc950209d6254b109e23b4b05e7811649f59eae5659fa58 # v0.6.3
with:
entrypoint: "/kubeconform"
args: "-strict -summary -output json --kubernetes-version ${{ matrix.kubernetes_version }} config/deploy/${{ matrix.environment }}.rendered.yaml"
frizbee:
name: Frizbee
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: segiddins/frizbee-action@c162fdaa6c73525a577d2d6eb193683dfc9ba2be # segiddins/run-in-place
env:
GITHUB_TOKEN: ${{ github.token }}
with:
action_paths: '[".github/workflows", ".github/actions"]'
dockerfiles: '["./Dockerfile", ".devcontainer/Dockerfile"]'
docker_compose: '["./docker-compose.yml", ".devcontainer/docker-compose.yml"]'
fail_on_unpinned: true
open_pr: false
repo_root: "."
8 changes: 4 additions & 4 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permissions: read-all
jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
Expand All @@ -32,12 +32,12 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v3.1.0
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand Down Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
uses: github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
sarif_file: results.sarif
20 changes: 14 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
status_check:
name: All required tests passing check
needs: [rails]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: always()
steps:
- run: /bin/${{ (needs.rails.result == 'success' || needs.rails.result == 'skipped') }}
Expand All @@ -26,44 +26,52 @@ jobs:
matrix:
rubygems:
- name: locked
version: "3.5.14"
version: "3.5.20"
- name: latest
version: latest
ruby_version: ["3.3.3"]
ruby_version: ["3.3.5"]
tests:
- name: general
command: test
- name: system
command: test:system
include:
- rubygems: { name: latest, version: latest }
ruby_version: "3.3.5"
tests: { name: "avo without pro", command: "test test/*/avo" }
name: Rails tests ${{ matrix.tests.name }} (RubyGems ${{ matrix.rubygems.name }}, Ruby ${{ matrix.ruby_version }})
runs-on: ubuntu-22.04
env:
RUBYGEMS_VERSION: ${{ matrix.rubygems.version }}
# Fail hard when Toxiproxy is not running to ensure all tests (even Toxiproxy optional ones) are passing
REQUIRE_TOXIPROXY: true
REQUIRE_AVO_PRO: ${{ github.secret_source != 'None' && matrix.tests.name != 'avo without pro' }}
AVO_LICENSE_KEY: ${{ secrets.AVO_LICENSE_KEY }}
BUNDLE_PACKAGER__DEV: ${{ secrets.BUNDLE_PACKAGER__DEV }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup rubygems.org
uses: ./.github/actions/setup-rubygems.org
with:
ruby-version: ${{ matrix.ruby_version }}
rubygems-version: ${{ matrix.rubygems.version }}
install-avo-pro: ${{ matrix.tests.name != 'avo without pro' }}

- name: Tests ${{ matrix.tests.name }}
id: test-all
run: bin/rails ${{ matrix.tests.command }}

- name: Save capybara screenshots
if: ${{ failure() && steps.test-all.outcome == 'failure' }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: capybara-screenshots-${{ matrix.tests.name }}-${{ matrix.rubygems.name }}
path: tmp/capybara
if-no-files-found: ignore

- name: Upload coverage to Codecov
if: matrix.rubygems.name == 'locked' && (success() || failure())
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@3b1354a6c45db9f1008891f4eafc1a7e94ce1d18 # v5.0.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Loading

0 comments on commit 12115bd

Please sign in to comment.