Skip to content

Commit fdb27bb

Browse files
committed
IC gh
1 parent cb43fc1 commit fdb27bb

File tree

5 files changed

+243
-111
lines changed

5 files changed

+243
-111
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/codeql.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "main", "v2.2" ]
17+
pull_request:
18+
branches: [ "main", "v2.2" ]
19+
schedule:
20+
- cron: '38 13 * * 4'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: actions
47+
build-mode: none
48+
- language: javascript-typescript
49+
build-mode: none
50+
- language: ruby
51+
build-mode: none
52+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
53+
# Use `c-cpp` to analyze code written in C, C++ or both
54+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
55+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
56+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
57+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
58+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
59+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
64+
# Add any setup steps before running the `github/codeql-action/init` action.
65+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
66+
# or others). This is typically only required for manual builds.
67+
# - name: Setup runtime (example)
68+
# uses: actions/setup-example@v1
69+
70+
# Initializes the CodeQL tools for scanning.
71+
- name: Initialize CodeQL
72+
uses: github/codeql-action/init@v3
73+
with:
74+
languages: ${{ matrix.language }}
75+
build-mode: ${{ matrix.build-mode }}
76+
# If you wish to specify custom queries, you can do so here or in a config file.
77+
# By default, queries listed here will override any specified in a config file.
78+
# Prefix the list here with "+" to use these queries and those in the config file.
79+
80+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
81+
# queries: security-extended,security-and-quality
82+
83+
# If the analyze step fails for one of the languages you are analyzing with
84+
# "We were unable to automatically build your code", modify the matrix above
85+
# to set the build mode to "manual" for that language. Then modify this step
86+
# to build your code.
87+
# ℹ️ Command-line programs to run using the OS shell.
88+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
89+
- if: matrix.build-mode == 'manual'
90+
shell: bash
91+
run: |
92+
echo 'If you are using a "manual" build mode for one or more of the' \
93+
'languages you are analyzing, replace this with the commands to build' \
94+
'your code, for example:'
95+
echo ' make bootstrap'
96+
echo ' make release'
97+
exit 1
98+
99+
- name: Perform CodeQL Analysis
100+
uses: github/codeql-action/analyze@v3
101+
with:
102+
category: "/language:${{matrix.language}}"

.github/workflows/rubyonrails.yml

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,58 @@
1-
# This workflow uses actions that are not certified by GitHub. They are
2-
# provided by a third-party and are governed by separate terms of service,
3-
# privacy policy, and support documentation.
1+
# Este flujo de trabajo emplea acciones que no están certificadas por Github.
2+
# Son proveidas por un tercero y están gobernadas por diferentes
3+
# términos de servicio, política de privacidad y documentación.
44
#
5-
# This workflow will install a prebuilt Ruby version, install dependencies, and
6-
# run tests and linters.
7-
name: "Ruby on Rails CI"
5+
# Este flujo de trabajo instalará una versión preconstruida de Ruby,
6+
# instalará dependencias y ejecutará pruebas y verificadores.
7+
name: "IC para Ruby on Rails"
88
on:
99
push:
10-
branches: [ "main" ]
10+
branches: [ "main", "v2.2" ]
1111
pull_request:
12-
branches: [ "main" ]
12+
branches: [ "main", "v2.2" ]
13+
env:
14+
DB_HOST: localhost
1315
jobs:
1416
test:
1517
runs-on: ubuntu-latest
16-
services:
17-
postgres:
18-
image: postgres:14-alpine
19-
ports:
20-
- "5432:5432"
21-
env:
22-
POSTGRES_DB: rails_test
23-
POSTGRES_USER: rails
24-
POSTGRES_PASSWORD: password
25-
BD_CLAVE: password
26-
BD_USUARIO: rails
27-
BD_PRUEBA: rails_test
2818
env:
2919
RAILS_ENV: test
3020
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
3121
steps:
32-
- name: Checkout code
22+
- name: Sacar código fuente
3323
uses: actions/checkout@v3
34-
# Add or replace dependency steps here
35-
- name: Install Ruby and gems
36-
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
24+
# Agregue o remplace pasos de depencicas aquí
25+
- name: Ambiente - paquetes e.g postgresql, postgis, base de pruebas, .env
26+
run: sudo ./bin/ambiente_github.sh
27+
- name: Instalar Ruby y gemas
28+
uses: ruby/setup-ruby@v1
3729
with:
30+
ruby-version: '3.4.5'
3831
bundler-cache: true
39-
# Add or replace database setup steps here
40-
- name: Set up database schema
41-
run: (cd test/dummy; cp .env.plantilla .env; bin/rails db:schema:load)
42-
# Add or replace test runners here
43-
- name: Run tests
44-
run: CONFIG_HOSTS=www.example.com bin/rails test
32+
- name: Reiniciar PostgreSQL
33+
run: ( sudo service postgresql restart; sudo systemctl restart postgresql.service)
34+
- name: Modificar estructura BD para que operen en versiones antiguas
35+
run: (export D=./; if (test -d "test/dummy") then { export D=test/dummy/; } fi; cp $D/db/structure.sql $D/db/structure.sql.copia; sed -e 's/provider = libc,//g;s/SET default_table_access_method.*/-- &/g;s/SET transaction_timeout.*//g' $D/db/structure.sql.copia > $D/db/structure.sql )
36+
- name: Modificar semillas BD para que operen en versiones antiguas
37+
run: (if (test -f "db/datos-basicas.sql") then { cp db/datos-basicas.sql db/datos-basicas.sql.copia; sed -e 's/provider = libc,//g;s/SET default_table_access_method.*/-- &/g;s/SET transaction_timeout.*//g' db/datos-basicas.sql.copia > db/datos-basicas.sql; } fi; )
38+
# Agregue o remplace ejecutores de pruebas aquí
39+
- name: Ejecutar pruebas
40+
run: NOPRUEBAJS=1 bin/regresion.sh
4541

4642
lint:
4743
runs-on: ubuntu-latest
4844
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v3
51-
- name: Install Ruby and gems
52-
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
45+
- name: Sacar código fuente
46+
uses: actions/checkout@v4
47+
- name: Instalar Ruby y gemas
48+
uses: ruby/setup-ruby@v1
5349
with:
50+
ruby-version: '3.4.5'
5451
bundler-cache: true
55-
# Add or replace any other lints here
56-
- name: Security audit dependencies
57-
run: bin/bundler-audit --update
58-
- name: Security audit application code
59-
run: bin/brakeman -q -w2
60-
- name: Lint Ruby files
61-
run: bin/rubocop --parallel
52+
# Agregue o remplace verificadores
53+
- name: Verificación de seguridad a dependencias ruby
54+
run: (bin/bundler-audit --update || exit_code=$?; echo "exit_code=$exit_code")
55+
- name: Verificación de seguridad a código Ruby de la aplicación
56+
run: (bin/brakeman -q -w2 || exit_code=$?; echo "exit_code=$exit_code")
57+
- name: Verificación al formato de código Ruby
58+
run: (bin/rubocop --parallel || exit_code=$?; echo "exit_code=$exit_code")

bin/ambiente_github.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
# Este script pepara un codspace/action de github con locale, paquetes
4+
# (e.g PostgreSQL, # PostGIS), base de datos y variables de ambiente
5+
# para correr la aplicación de prueba y/o las pruebas
6+
7+
# pdftoppm en poppler-utils
8+
echo "Ejecutando ambiente_github.sh"
9+
sudo apt update
10+
sudo apt install -y poppler-utils
11+
sudo locale-gen es_CO.UTF-8 && sudo update-locale
12+
13+
# Instala PostgreSQL 17 y PostGIS 3 y las librerías requeridas
14+
if (test ! -f /etc/postgresql/17/main/pg_hba.conf) then {
15+
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/postgresql.asc
16+
echo 'deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/postgresql.asc] https://apt.postgresql.org/pub/repos/apt/ noble-pgdg main' | sudo tee /etc/apt/sources.list.d/pgdg.list
17+
sudo apt update
18+
sudo apt install -y postgresql-17 postgresql-client-17
19+
sudo apt install -y postgis postgresql-17-postgis-3
20+
sudo pg_createcluster 17 main --start
21+
sudo sed -i "s|local.*all.*all.*peer|local all all md5|g" /etc/postgresql/17/main/pg_hba.conf
22+
sudo cat /etc/postgresql/17/main/pg_hba.conf
23+
} fi;
24+
echo "Reiniciando postgresql"
25+
sudo service postgresql restart
26+
echo "PostgreSQL reiniciado"
27+
28+
psql --version
29+
30+
# Crea usuario y base de datos como usuario postgres
31+
echo "Creando usuario"
32+
sudo su - postgres -c "createuser -s rails"
33+
echo "Cambiando clave"
34+
sudo su - postgres -c "psql -c \"ALTER USER rails WITH PASSWORD 'password';\""
35+
echo "Facilitando uso"
36+
echo "*:*:*:rails:password" >> ~/.pgpass
37+
chmod 0600 ~/.pgpass
38+
echo ":::: cat ~/.pgpass::::"
39+
cat ~/.pgpass
40+
echo "Creando base"
41+
sudo su - postgres -c "createdb -O rails rails_test"
42+
echo "Creada"
43+
44+
# Configura el ambiente
45+
cd "$(dirname "$0")/.." || exit 1
46+
if (test -d test/dummy) then {
47+
cd test/dummy
48+
} fi;
49+
pwd
50+
cp .env.github .env
51+
echo "::::.env antes de modificar es::::"
52+
cat .env
53+
54+
# Modifica el archivo .env con rutas locales y configuraciones
55+
DIRAP=$(pwd)
56+
sed -i "s|export DIRAP=.*|export DIRAP=${DIRAP}/|g" .env
57+
#sed -i "s|export BD_SERVIDOR=.*|export BD_SERVIDOR=localhost|g" .env
58+
echo "export RAILS_ENV=test" >> .env
59+
60+
echo "::::.env tras modificacion es es::::"
61+
cat .env
62+
63+
# Ejecuta el archivo con variables de ambiente
64+
source .env
65+
66+
echo "¡Ambiente configurado con exito!"
67+
echo "Directorio de la aplicaciónde datos: $DIRAP"
68+
echo "Base de datos: $BD_PRUEBA"
69+
echo "Usuario: $BD_USUARIO"
70+
echo "host: $BD_SERVIDOR"
71+
echo "Localización del archivo de ambiente: $DIRAP/.env"
72+
73+
# bundle
74+
# RAILS_ENV=test bin/rails dbconsole
75+

test/dummy/.env.github

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
# Variables de configuración de la aplicación
3+
# Damos precedencia a las especificadas en línea de ordenes
4+
5+
export DIRAP="/home/runner/work/sivel2_gen/sivel2_gen/test/dummy"
6+
7+
. ./.env.plantilla
8+
9+
echo "MSIP_RUTA_VOLCADOS=${MSIP_RUTA_VOLCADOS}"
10+
echo "BD_NOMBRE=${BD_NOMBRE}"
11+
12+
export MSIP_RUTA_VOLCADOS="${DIRAP}/archivos/bd/"
13+
export MSIP_RUTA_ANEXOS="${DIRAP}/archivos/anexos/"
14+
echo "MSIP_RUTA_VOLCADOS=${MSIP_RUTA_VOLCADOS}"
15+
16+
export BD_USUARIO=rails
17+
export BD_CLAVE="password"
18+
export BD_PRUEBA="rails_test"
19+
export BD_SERVIDOR=localhost
20+
21+
export RUTA_RELATIVA="/sivel2/"
22+
23+
# Despliegue
24+
export CONFIG_HOSTS=www.example.com/
25+
26+
export CI="Si"
27+
28+
export NOPRUEBAJS=1

0 commit comments

Comments
 (0)