diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef8eeef..e6b731f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,11 +6,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Install dependencies + run: bundle install - name: Build run: | git config user.name github-actions git config user.email github-actions@github.com - ruby build.rb + bundle exec ruby build.rb if ! git diff --exit-code then git add . diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..6393cf2 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,6 @@ + + Layout/HashAlignment: + Enabled: false + + Layout/LeadingEmptyLines: + Enabled: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..632fced --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "liquid" +gem "base64" +gem "cgi" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..29d32bb --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,29 @@ +GEM + remote: https://rubygems.org/ + specs: + base64 (0.3.0) + bigdecimal (4.1.2) + cgi (0.5.1) + liquid (5.12.0) + bigdecimal + strscan (>= 3.1.1) + strscan (3.1.8) + +PLATFORMS + arm64-darwin-24 + ruby + +DEPENDENCIES + base64 + cgi + liquid + +CHECKSUMS + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd + cgi (0.5.1) sha256=e93fcafc69b8a934fe1e6146121fa35430efa8b4a4047c4893764067036f18e9 + liquid (5.12.0) sha256=5a3c2c2430cd925d21c53e4ed9abea52cd0a9da53b541422f81dee79aca2a673 + strscan (3.1.8) sha256=aae2db611a225559f21ffbb71765c9a4e60fd262534a9ea84f4f11c7f32f679e + +BUNDLED WITH + 4.0.10 diff --git a/LINUX_keep_current.md b/LINUX_keep_current.md index 067667d..8131cac 100644 --- a/LINUX_keep_current.md +++ b/LINUX_keep_current.md @@ -86,10 +86,12 @@ type -a pyenv > /dev/null && eval "$(pyenv init --path)" Update pyenv : + ``` bash cd $(pyenv root) && git pull ``` + Install the current python version : ```bash @@ -140,10 +142,12 @@ pyenv versions pip install -U pip ``` + ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` + ## GCP Make sure that the `gcloud` command is linked to the email address of your Google Cloud Platform account : @@ -212,8 +216,7 @@ cat $GOOGLE_APPLICATION_CREDENTIALS { "type": "service_account", "project_id": "your-gcp-project-id", - "private_key_id": "a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInM=\n-----END PRIVATE KEY-----\n", + "private_key_id": "...", "client_email": "your-service-account@your-service-account.iam.gserviceaccount.com", "client_id": "105410541054105410541", "auth_uri": "https://accounts.google.com/o/oauth2/auth", @@ -252,12 +255,14 @@ gcloud auth configure-docker ## Docker + Start Docker : ``` bash sudo service docker start ``` + Verify that Docker can run the hello-world image : ``` bash @@ -266,6 +271,7 @@ docker run hello-world 👉 Make sure that this command completes correctly + Start Docker : ``` bash @@ -273,21 +279,22 @@ sudo service docker stop ``` + ### Python setup check up Check your Python version with the following commands: ```bash -zsh -c "$(curl -fsSL )" 3.8.12 +zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh)" 3.8.12 ``` Run the following command to check if you successfully installed the required packages: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh)" ``` Now run the following command to check if you can load these packages: ```bash -python -c "$(curl -fsSL )" +python -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py)" ``` Make sure you can run Jupyter: diff --git a/WINDOWS_keep_current.md b/WINDOWS_keep_current.md index 3a687df..aa7acbf 100644 --- a/WINDOWS_keep_current.md +++ b/WINDOWS_keep_current.md @@ -86,10 +86,12 @@ type -a pyenv > /dev/null && eval "$(pyenv init --path)" Update pyenv : + ``` bash cd $(pyenv root) && git pull ``` + Install the current python version : ```bash @@ -140,10 +142,12 @@ pyenv versions pip install -U pip ``` + ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` + ## GCP Make sure that the `gcloud` command is linked to the email address of your Google Cloud Platform account : @@ -212,8 +216,7 @@ cat $GOOGLE_APPLICATION_CREDENTIALS { "type": "service_account", "project_id": "your-gcp-project-id", - "private_key_id": "a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInM=\n-----END PRIVATE KEY-----\n", + "private_key_id": "...", "client_email": "your-service-account@your-service-account.iam.gserviceaccount.com", "client_id": "105410541054105410541", "auth_uri": "https://accounts.google.com/o/oauth2/auth", @@ -252,12 +255,14 @@ gcloud auth configure-docker ## Docker + Start Docker : ``` bash sudo service docker start ``` + Verify that Docker can run the hello-world image : ``` bash @@ -266,6 +271,7 @@ docker run hello-world 👉 Make sure that this command completes correctly + Start Docker : ``` bash @@ -281,21 +287,22 @@ wsl --shutdown If the command still does not work, try to restart your Windows machine + ### Python setup check up Check your Python version with the following commands: ```bash -zsh -c "$(curl -fsSL )" 3.8.12 +zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh)" 3.8.12 ``` Run the following command to check if you successfully installed the required packages: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh)" ``` Now run the following command to check if you can load these packages: ```bash -python -c "$(curl -fsSL )" +python -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py)" ``` Make sure you can run Jupyter: diff --git a/_partials/dotfiles.md b/_partials/dotfiles.md index 94ffe14..034b086 100644 --- a/_partials/dotfiles.md +++ b/_partials/dotfiles.md @@ -15,10 +15,10 @@ Open your terminal and go to your `dotfiles` project: ```bash cd ~/code//dotfiles - . # Open it in +{{ CODE_EDITOR_CMD }} . # Open it in {{ CODE_EDITOR }} ``` -In , open the `zshrc` file. Replace its content with the [newest version](https://raw.githubusercontent.com/lewagon/dotfiles/master/zshrc) of that file that we provide. Save to disk. +In {{ CODE_EDITOR }}, open the `zshrc` file. Replace its content with the [newest version](https://raw.githubusercontent.com/lewagon/dotfiles/master/zshrc) of that file that we provide. Save to disk. Back to the terminal, run a `git diff` and ask a TA to come and check about this configuration change. You should see stuff about Python and `pyenv`. diff --git a/_partials/es/dotfiles.md b/_partials/es/dotfiles.md index 5d3d261..cd580d4 100644 --- a/_partials/es/dotfiles.md +++ b/_partials/es/dotfiles.md @@ -13,10 +13,10 @@ Abre tu terminal y ve a tu proyecto `dotfiles`: ```bash cd ~/code//dotfiles - . # Open it in +{{ CODE_EDITOR_CMD }} . # Open it in {{ CODE_EDITOR }} ``` -En abre el archivo `zshrc`. Reemplaza su contenido con la [versión más reciente](https://raw.githubusercontent.com/lewagon/dotfiles/master/zshrc) de ese archivo que te suministramos. Luego guárdalo en el disco. +En {{ CODE_EDITOR }}abre el archivo `zshrc`. Reemplaza su contenido con la [versión más reciente](https://raw.githubusercontent.com/lewagon/dotfiles/master/zshrc) de ese archivo que te suministramos. Luego guárdalo en el disco. Regresa a la terminal y ejecuta un `git diff` y pídele a un TA que venga y verifique este cambio de configuración. Debería ver cosas de Python y `pyenv`. diff --git a/_partials/es/keep_current.md b/_partials/es/keep_current.md index 5053334..71e13e6 100644 --- a/_partials/es/keep_current.md +++ b/_partials/es/keep_current.md @@ -86,26 +86,24 @@ type -a pyenv > /dev/null && eval "$(pyenv init --path)" Actualiza pyenv: -$MAC_START +{% if os == "macos" %} ``` bash brew update && brew upgrade pyenv ``` -$MAC_END -$LINUX_START +{% elsif os == "linux" %} ``` bash cd $(pyenv root) && git pull ``` -$LINUX_END -$WINDOWS_START +{% elsif os == "windows" %} ``` bash cd $(pyenv root) && git pull ``` -$WINDOWS_END +{% endif %} Instala la versión actual de python: ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` 👉 Asegúrate de que el comando se ejecute completamente y luego **reinicia tu terminal**. @@ -119,7 +117,7 @@ pyenv virtualenv-delete lewagon_current Crea un nuevo ambiente virtual: ```bash -pyenv virtualenv lewagon_current +pyenv virtualenv {{ PYTHON_VERSION }} lewagon_current ``` Define el nuevo ambiente virtual como predeterminado: @@ -138,8 +136,8 @@ pyenv versions ``` bash system - - /envs/lewagon_current + {{ PYTHON_VERSION }} + {{ PYTHON_VERSION }}/envs/lewagon_current 3.7.6 3.7.6/envs/lewagon * lewagon_current @@ -152,7 +150,7 @@ pyenv versions pip install -U pip ``` -$MAC_START +{% if os == "macos" %} Si tu computadora usa **Apple Silicon**, expande el párrafo de abajo y léelo. Si no es el caso, ignóralo.
@@ -172,17 +170,15 @@ Si tu computadora usa **Apple Intel**, expande el párrafo de abajo y léelo. Si pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/apple_intel.txt ```
-$MAC_END -$WINDOWS_START +{% elsif os == "windows" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$WINDOWS_END -$LINUX_START +{% elsif os == "linux" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$LINUX_END +{% endif %} ## GCP @@ -252,8 +248,7 @@ cat $GOOGLE_APPLICATION_CREDENTIALS { "type": "service_account", "project_id": "your-gcp-project-id", - "private_key_id": "a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInM=\n-----END PRIVATE KEY-----\n", + "private_key_id": "...", "client_email": "your-service-account@your-service-account.iam.gserviceaccount.com", "client_id": "105410541054105410541", "auth_uri": "https://accounts.google.com/o/oauth2/auth", @@ -292,23 +287,21 @@ gcloud auth configure-docker ## Docker -$MAC_START +{% if os == "macos" %} Start the Docker app -$MAC_END -$LINUX_START +{% elsif os == "linux" %} Start Docker : ``` bash sudo service docker start ``` -$LINUX_END -$WINDOWS_START +{% elsif os == "windows" %} Start Docker : ``` bash sudo service docker start ``` -$WINDOWS_END +{% endif %} Verifica que Docker pueda ejecutar la imagen de hello-world: @@ -318,17 +311,15 @@ docker run hello-world 👉 Asegúrate de que este comando se ejecute completamente -$MAC_START +{% if os == "macos" %} Stop the Docker app -$MAC_END -$LINUX_START +{% elsif os == "linux" %} Start Docker : ``` bash sudo service docker stop ``` -$LINUX_END -$WINDOWS_START +{% elsif os == "windows" %} Start Docker : ``` bash @@ -342,4 +333,4 @@ wsl --shutdown ``` Si después de eso el comando sigue sin funcionar, intenta reiniciar tu máquina Windows -$WINDOWS_END +{% endif %} diff --git a/_partials/es/nbextensions.md b/_partials/es/nbextensions.md index 53dada4..a20bb6b 100644 --- a/_partials/es/nbextensions.md +++ b/_partials/es/nbextensions.md @@ -20,7 +20,7 @@ Abre `custom/custom.css` en el directorio config: cd $(jupyter --config-dir) mkdir -p custom touch custom/custom.css - custom/custom.css +{{ CODE_EDITOR_CMD }} custom/custom.css ``` Edita `custom.css` con la siguiente información: @@ -34,7 +34,7 @@ summary::marker { } ``` -Puedes cerrar . +Puedes cerrar {{ CODE_EDITOR }}. ### Chequeo de `jupyter` diff --git a/_partials/es/osx_python.md b/_partials/es/osx_python.md index b7ddd1e..7c1c3e3 100644 --- a/_partials/es/osx_python.md +++ b/_partials/es/osx_python.md @@ -32,7 +32,7 @@ exec zsh Instala la [última versión estable de Python](https://www.python.org/doc/versions/) que sea aceptada en el currículum de Le Wagon: ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` Este comando puede tomar un tiempo en ejecutarse. Esto es completamente normal. ¡No dudes en ayudar a los estudiantes que estén sentados cerca de ti! @@ -57,7 +57,7 @@ export CPPFLAGS="-I/usr/local/opt/zlib/include" Luego trata de instalar Python nuevamente: ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` Es posible que aparezca otro error relacionado con `bzip2`. Esto lo puedes ignorar y continuar al paso siguiente. @@ -68,8 +68,8 @@ Es posible que aparezca otro error relacionado con `bzip2`. Esto lo puedes ignor OK. Cuando este comando termine de ejecutarse, le diremos al sistema que use esta versión de Python **por defecto**. Esto se hace con: ```bash -pyenv global +pyenv global {{ PYTHON_VERSION }} exec zsh ``` -Para verificar si esto ha funcionado, ejecuta `python --version`. Si ves ``, ¡todo está bien! Si no, pídele ayuda a un TA para resolver el problema por medio `versiones de pyenv` y `type -a python` (`python` debería estar usando la versión `.pyenv/shims` de primero). +Para verificar si esto ha funcionado, ejecuta `python --version`. Si ves `{{ PYTHON_VERSION }}`, ¡todo está bien! Si no, pídele ayuda a un TA para resolver el problema por medio `versiones de pyenv` y `type -a python` (`python` debería estar usando la versión `.pyenv/shims` de primero). diff --git a/_partials/es/pip.md b/_partials/es/pip.md index ae38859..81a1194 100644 --- a/_partials/es/pip.md +++ b/_partials/es/pip.md @@ -10,7 +10,7 @@ pip install --upgrade pip Ahora instala algunos paquetes para las primeras semanas del programa: -$MAC_START +{% if os == "macos" %} Si tu computadora usa **Apple Silicon**, expande el párrafo de abajo y léelo. Si no es el caso, ignóralo.
@@ -30,14 +30,12 @@ Si tu computadora usa **Apple Intel**, expande el párrafo de abajo y léelo. Si pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/apple_intel.txt ```
-$MAC_END -$WINDOWS_START +{% elsif os == "windows" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$WINDOWS_END -$LINUX_START +{% elsif os == "linux" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$LINUX_END +{% endif %} diff --git a/_partials/es/python_checkup.md b/_partials/es/python_checkup.md index d50805b..dc84f4f 100644 --- a/_partials/es/python_checkup.md +++ b/_partials/es/python_checkup.md @@ -2,17 +2,17 @@ Verifica tu versión de Python con los siguientes comandos: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL {{ PYTHON_CHECKER_URL }})" {{ PYTHON_VERSION }} ``` Ejecuta el comando siguiente para verificar que hayas instalado los paquetes requeridos correctamente: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL {{ PIP_CHECKER_URL }})" ``` Ahora ejecuta el siguiente comando para verificar que puedas cargar estos paquetes: ```bash -python -c "$(curl -fsSL )" +python -c "$(curl -fsSL {{ PIP_LOADER_URL }})" ``` Asegúrate de que puedas usar Jupyter: diff --git a/_partials/es/ubuntu_python.md b/_partials/es/ubuntu_python.md index 06982ed..91bef20 100644 --- a/_partials/es/ubuntu_python.md +++ b/_partials/es/ubuntu_python.md @@ -23,7 +23,7 @@ python-dev python3-dev Instala la [última versión estable de Python](https://www.python.org/doc/versions/) que sea aceptada en el currículum de Le Wagon: ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` Este comando puede tomar un tiempo en ejecutarse. Esto es completamente normal. ¡No dudes en ayudar a los estudiantes que estén sentados cerca de ti! @@ -31,8 +31,8 @@ Este comando puede tomar un tiempo en ejecutarse. Esto es completamente normal. OK. Cuando este comando termine de ejecutarse, le diremos al sistema que use esta versión de Python **por defecto**. Esto se hace con: ```bash -pyenv global +pyenv global {{ PYTHON_VERSION }} exec zsh ``` -Para verificar que esto haya funcionado, ejecuta `python --version`. Si ves ``, ¡todo está bien! Si no, pídele ayuda a un TA para resolver el problema por medio de `versiones de pyenv` y `type -a python` (`python` debería estar usando la versión `.pyenv/shims` de primero). +Para verificar que esto haya funcionado, ejecuta `python --version`. Si ves `{{ PYTHON_VERSION }}`, ¡todo está bien! Si no, pídele ayuda a un TA para resolver el problema por medio de `versiones de pyenv` y `type -a python` (`python` debería estar usando la versión `.pyenv/shims` de primero). diff --git a/_partials/es/virtualenv.md b/_partials/es/virtualenv.md index 462f697..69b2499 100644 --- a/_partials/es/virtualenv.md +++ b/_partials/es/virtualenv.md @@ -12,7 +12,7 @@ exec zsh Crea el entorno virtual que usaremos durante todo el bootcamp: ```bash -pyenv virtualenv lewagon +pyenv virtualenv {{ PYTHON_VERSION }} lewagon ``` Define el entorno virtual con lo siguiente: diff --git a/_partials/es/win_jupyter.md b/_partials/es/win_jupyter.md index 932ad32..3c6e1fb 100644 --- a/_partials/es/win_jupyter.md +++ b/_partials/es/win_jupyter.md @@ -12,7 +12,7 @@ jupyter notebook --generate-config Ahora edita el archivo de configuración de Jupyter generado: ``` bash - $HOME/.jupyter/jupyter_notebook_config.py +{{ CODE_EDITOR_CMD }} $HOME/.jupyter/jupyter_notebook_config.py ``` Localiza la siguiente línea en el archivo de configuración: diff --git a/_partials/keep_current.md b/_partials/keep_current.md index df45132..7076250 100644 --- a/_partials/keep_current.md +++ b/_partials/keep_current.md @@ -86,26 +86,24 @@ type -a pyenv > /dev/null && eval "$(pyenv init --path)" Update pyenv : -$MAC_START +{% if os == "macos" %} ``` bash brew update && brew upgrade pyenv ``` -$MAC_END -$LINUX_START +{% elsif os == "linux" %} ``` bash cd $(pyenv root) && git pull ``` -$LINUX_END -$WINDOWS_START +{% elsif os == "windows" %} ``` bash cd $(pyenv root) && git pull ``` -$WINDOWS_END +{% endif %} Install the current python version : ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` 👉 Make sure that the command completes correctly and **restart your terminal** @@ -119,7 +117,7 @@ pyenv virtualenv-delete lewagon_current Create a new virtual environment : ```bash -pyenv virtualenv lewagon_current +pyenv virtualenv {{ PYTHON_VERSION }} lewagon_current ``` Set the new virtual environment as default : @@ -138,8 +136,8 @@ pyenv versions ``` bash system - - /envs/lewagon_current + {{ PYTHON_VERSION }} + {{ PYTHON_VERSION }}/envs/lewagon_current 3.7.6 3.7.6/envs/lewagon * lewagon_current @@ -152,7 +150,7 @@ pyenv versions pip install -U pip ``` -$MAC_START +{% if os == "macos" %} If your computer uses **Apple Silicon**, expand the paragraph below and go through it. Otherwise ignore it.
@@ -172,17 +170,15 @@ If your computer uses **Apple Intel**, expand the paragraph below and go through pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/apple_intel.txt ```
-$MAC_END -$WINDOWS_START +{% elsif os == "windows" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$WINDOWS_END -$LINUX_START +{% elsif os == "linux" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$LINUX_END +{% endif %} ## GCP @@ -252,8 +248,7 @@ cat $GOOGLE_APPLICATION_CREDENTIALS { "type": "service_account", "project_id": "your-gcp-project-id", - "private_key_id": "a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInM=\n-----END PRIVATE KEY-----\n", + "private_key_id": "...", "client_email": "your-service-account@your-service-account.iam.gserviceaccount.com", "client_id": "105410541054105410541", "auth_uri": "https://accounts.google.com/o/oauth2/auth", @@ -292,23 +287,21 @@ gcloud auth configure-docker ## Docker -$MAC_START +{% if os == "macos" %} Start the Docker app -$MAC_END -$LINUX_START +{% elsif os == "linux" %} Start Docker : ``` bash sudo service docker start ``` -$LINUX_END -$WINDOWS_START +{% elsif os == "windows" %} Start Docker : ``` bash sudo service docker start ``` -$WINDOWS_END +{% endif %} Verify that Docker can run the hello-world image : @@ -318,17 +311,15 @@ docker run hello-world 👉 Make sure that this command completes correctly -$MAC_START +{% if os == "macos" %} Stop the Docker app -$MAC_END -$LINUX_START +{% elsif os == "linux" %} Start Docker : ``` bash sudo service docker stop ``` -$LINUX_END -$WINDOWS_START +{% elsif os == "windows" %} Start Docker : ``` bash @@ -342,4 +333,4 @@ wsl --shutdown ``` If the command still does not work, try to restart your Windows machine -$WINDOWS_END +{% endif %} diff --git a/_partials/nbextensions.md b/_partials/nbextensions.md index 5d0a698..a1e5e04 100644 --- a/_partials/nbextensions.md +++ b/_partials/nbextensions.md @@ -20,7 +20,7 @@ Open `custom/custom.css` in the config directory: cd $(jupyter --config-dir) mkdir -p custom touch custom/custom.css - custom/custom.css +{{ CODE_EDITOR_CMD }} custom/custom.css ``` Edit `custom.css` with: @@ -34,7 +34,7 @@ summary::marker { } ``` -You can close . +You can close {{ CODE_EDITOR }}. ### `jupyter` check up diff --git a/_partials/osx_python.md b/_partials/osx_python.md index b659a56..c6158df 100644 --- a/_partials/osx_python.md +++ b/_partials/osx_python.md @@ -32,7 +32,7 @@ exec zsh Let's install the [latest stable version of Python](https://www.python.org/doc/versions/) supported by Le Wagon's curriculum: ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` This command might take a while, this is perfectly normal. Don't hesitate to help other students seated next to you! @@ -57,7 +57,7 @@ export CPPFLAGS="-I/usr/local/opt/zlib/include" Then try to install Python again: ```bash -pyenv install +pyenv install {{ PYTHON_VERSION }} ``` It could raise another error about `bzip2`, you can ignore it and continue to the next step. @@ -68,8 +68,8 @@ It could raise another error about `bzip2`, you can ignore it and continue to th OK once this command is complete, we are going to tell the system to use this version of Python **by default**. This is done with: ```bash -pyenv global +pyenv global {{ PYTHON_VERSION }} exec zsh ``` -To check if this worked, run `python --version`. If you see ``, perfect! If not, ask a TA that will help you debug the problem thanks to `pyenv versions` and `type -a python` (`python` should be using the `.pyenv/shims` version first). +To check if this worked, run `python --version`. If you see `{{ PYTHON_VERSION }}`, perfect! If not, ask a TA that will help you debug the problem thanks to `pyenv versions` and `type -a python` (`python` should be using the `.pyenv/shims` version first). diff --git a/_partials/pip.md b/_partials/pip.md index 4392db5..5abe484 100644 --- a/_partials/pip.md +++ b/_partials/pip.md @@ -10,7 +10,7 @@ pip install --upgrade pip Then let's install some packages for the first weeks of the program: -$MAC_START +{% if os == "macos" %} If your computer uses **Apple Silicon**, expand the paragraph below and go through it. Otherwise ignore it.
@@ -30,14 +30,12 @@ If your computer uses **Apple Intel**, expand the paragraph below and go through pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/apple_intel.txt ```
-$MAC_END -$WINDOWS_START +{% elsif os == "windows" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$WINDOWS_END -$LINUX_START +{% elsif os == "linux" %} ``` bash pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/linux.txt ``` -$LINUX_END +{% endif %} diff --git a/_partials/python_checkup.md b/_partials/python_checkup.md index 363c219..9299275 100644 --- a/_partials/python_checkup.md +++ b/_partials/python_checkup.md @@ -2,17 +2,17 @@ Check your Python version with the following commands: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL {{ PYTHON_CHECKER_URL }})" {{ PYTHON_VERSION }} ``` Run the following command to check if you successfully installed the required packages: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL {{ PIP_CHECKER_URL }})" ``` Now run the following command to check if you can load these packages: ```bash -python -c "$(curl -fsSL )" +python -c "$(curl -fsSL {{ PIP_LOADER_URL }})" ``` Make sure you can run Jupyter: diff --git a/_partials/virtualenv.md b/_partials/virtualenv.md index 341f545..817e72b 100644 --- a/_partials/virtualenv.md +++ b/_partials/virtualenv.md @@ -12,7 +12,7 @@ exec zsh Let's create the virtual environment we are going to use during the whole bootcamp: ```bash -pyenv virtualenv lewagon +pyenv virtualenv {{ PYTHON_VERSION }} lewagon ``` Let's now set the virtual environment with: diff --git a/_partials/win_jupyter.md b/_partials/win_jupyter.md index 1a725e4..81c991f 100644 --- a/_partials/win_jupyter.md +++ b/_partials/win_jupyter.md @@ -12,7 +12,7 @@ jupyter notebook --generate-config We will now edit the generated Jupyter configuration file: ``` bash - $HOME/.jupyter/jupyter_notebook_config.py +{{ CODE_EDITOR_CMD }} $HOME/.jupyter/jupyter_notebook_config.py ``` Locate the following line in the configuration file: diff --git a/build.rb b/build.rb index 23013e4..702f5a5 100755 --- a/build.rb +++ b/build.rb @@ -1,184 +1,22 @@ -#!/usr/bin/env ruby -wU -CONSTANTS = { - 'PYTHON_VERSION' => '3.8.12', - # 'PYTHON_CHECKER_URL' => 'https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh', - # 'PIP_CHECKER_URL' => 'https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh', - # 'PIP_LOADER_URL' => 'https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py', - 'CODE_EDITOR' => 'VS Code', - 'CODE_EDITOR_CMD' => 'code' -} - -# NOTE(ssaunier): This script needs https://github.com/lewagon/setup to be cloned as well -MAC_OS = %w[ - intro - setup/macos_slack - setup/slack_settings - setup/github - ssh_key - gcp_setup - virtual_machine - osx_vscode - vscode_remote_ssh - vscode_extensions - cli_tools - setup/oh_my_zsh - setup/gh_cli - ubuntu_gcloud - gcp_setup_linux - dotfiles_simple - dotfiles_terminal - zsh_default_terminal - setup/ssh_agent - ubuntu_docker - kubernetes - terraform - ubuntu_spark - ubuntu_python - repo_overview - dbeaver - setup/kitt -].freeze - -MAC_OS_KC = %w[ - keep_current - python_checkup -].freeze - -WINDOWS = %w[ - intro - setup/windows_slack - setup/slack_settings - setup/github - ssh_key - gcp_setup - virtual_machine - win_vscode - vscode_remote_ssh - vscode_extensions - cli_tools - setup/oh_my_zsh - setup/gh_cli - ubuntu_gcloud - gcp_setup_linux - dotfiles_simple - dotfiles_terminal - zsh_default_terminal - setup/ssh_agent - ubuntu_docker - kubernetes - terraform - ubuntu_spark - ubuntu_python - repo_overview - dbeaver - setup/kitt -].freeze +#!/usr/bin/env ruby +# frozen_string_literal: true -WINDOWS_KC = %w[ - keep_current - python_checkup -].freeze +require 'yaml' +require_relative 'lib/builder' -LINUX = %w[ - intro - setup/ubuntu_slack - setup/slack_settings - setup/github - ssh_key - gcp_setup - virtual_machine - setup/ubuntu_vscode - vscode_remote_ssh - vscode_extensions - cli_tools - setup/oh_my_zsh - setup/gh_cli - ubuntu_gcloud - gcp_setup_linux - dotfiles_simple - dotfiles_terminal - zsh_default_terminal - setup/ssh_agent - ubuntu_docker - kubernetes - terraform - ubuntu_spark - ubuntu_python - repo_overview - dbeaver - setup/kitt -] +build_specs = Dir['builds/*.yml'].map { |filename| -LINUX_KC = %w[ - keep_current - python_checkup -] + data = YAML.load_file(filename) -LOCALES = [""] # english - -FILENAMES = { - "WINDOWS" => ["WINDOWS", WINDOWS], - "macOS" => ["macOS", MAC_OS], - "LINUX" => ["LINUX", LINUX], - "WINDOWS_keep_current" => ["WINDOWS", WINDOWS_KC], - "macOS_keep_current" => ["macOS", MAC_OS_KC], - "LINUX_keep_current" => ["LINUX", LINUX_KC] -} - -DELIMITERS = { - "WINDOWS" => ["\\$WINDOWS_START\n", "\\$WINDOWS_END\n"], - "macOS" => ["\\$MAC_START\n", "\\$MAC_END\n"], - "LINUX" => ["\\$LINUX_START\n", "\\$LINUX_END\n"] + BuildSpec.new( + name: File.basename(filename, '.yml'), + os: data['os'], + locales: data['locales'], + partials: data['partials'] + ) } -def load_partial(partial, locale) - match_data = partial.match(/setup\/(?[0-9a-z_]+)/) - partial = match_data[:partial] if match_data - partial = File.join(locale, partial) unless locale.empty? - file = File.join("_partials", "#{partial}.md") - if match_data - require 'open-uri' - content = URI.open(File.join("https://raw.githubusercontent.com/lewagon/setup/master", file)) - .string - # replace data-setup repo relative path by setup repo URL - image_paths = content.scan(/\!\[.*\]\((.*)\)/).flatten - image_paths.each { |ip| content.gsub!(ip, "https://github.com/lewagon/setup/blob/master/#{ip}")} - else - content = File.read(file, encoding: "utf-8") - end - return content -end - -# load partials -loaded = FILENAMES.map { |filename, (os_name, partials)| partials }.flatten.uniq -loaded = loaded.map { |partial| LOCALES.map { |locale| [partial, locale]} }.flatten(1) -loaded = loaded.map { |partial, locale| ["#{partial}.#{locale}", load_partial(partial, locale)] }.to_h +constants = YAML.load_file('constants/constants.yml').freeze +repos_cfg = YAML.load_file('constants/repos.yml').freeze -# write files -LOCALES.each do |locale| - FILENAMES.each do |filename, (os_name, partials)| - filename += ".#{locale}" unless locale.empty? - filename += ".md" - File.open(filename, "w:utf-8") do |f| - partials.each do |partial| - content = loaded["#{partial}.#{locale}"].clone - # remove the OS dependant blocks - removed_blocks = DELIMITERS.keys - [os_name] - removed_blocks.each do |block| - delimiter_start, delimiter_end = DELIMITERS[block] - pattern = "#{delimiter_start}(.|\n)*?(?", value) - end - f << content - f << "\n\n" - end - end - end -end +Builder.new(build_specs, constants, repos_cfg).run diff --git a/builds/LINUX.yml b/builds/LINUX.yml new file mode 100644 index 0000000..e27cec1 --- /dev/null +++ b/builds/LINUX.yml @@ -0,0 +1,31 @@ + +os: linux +locales: [en] +partials: + - intro + - setup/ubuntu_slack + - setup/slack_settings + - setup/github + - ssh_key + - gcp_setup + - virtual_machine + - setup/ubuntu_vscode + - vscode_remote_ssh + - vscode_extensions + - cli_tools + - setup/oh_my_zsh + - setup/gh_cli + - ubuntu_gcloud + - gcp_setup_linux + - dotfiles_simple + - dotfiles_terminal + - zsh_default_terminal + - setup/ssh_agent + - ubuntu_docker + - kubernetes + - terraform + - ubuntu_spark + - ubuntu_python + - repo_overview + - dbeaver + - setup/kitt diff --git a/builds/LINUX_keep_current.yml b/builds/LINUX_keep_current.yml new file mode 100644 index 0000000..f69e9d9 --- /dev/null +++ b/builds/LINUX_keep_current.yml @@ -0,0 +1,6 @@ + +os: linux +locales: [en] +partials: + - keep_current + - python_checkup diff --git a/builds/WINDOWS.yml b/builds/WINDOWS.yml new file mode 100644 index 0000000..e5140aa --- /dev/null +++ b/builds/WINDOWS.yml @@ -0,0 +1,31 @@ + +os: windows +locales: [en] +partials: + - intro + - setup/windows_slack + - setup/slack_settings + - setup/github + - ssh_key + - gcp_setup + - virtual_machine + - win_vscode + - vscode_remote_ssh + - vscode_extensions + - cli_tools + - setup/oh_my_zsh + - setup/gh_cli + - ubuntu_gcloud + - gcp_setup_linux + - dotfiles_simple + - dotfiles_terminal + - zsh_default_terminal + - setup/ssh_agent + - ubuntu_docker + - kubernetes + - terraform + - ubuntu_spark + - ubuntu_python + - repo_overview + - dbeaver + - setup/kitt diff --git a/builds/WINDOWS_keep_current.yml b/builds/WINDOWS_keep_current.yml new file mode 100644 index 0000000..e230908 --- /dev/null +++ b/builds/WINDOWS_keep_current.yml @@ -0,0 +1,6 @@ + +os: windows +locales: [en] +partials: + - keep_current + - python_checkup diff --git a/builds/macOS.yml b/builds/macOS.yml new file mode 100644 index 0000000..9827a7f --- /dev/null +++ b/builds/macOS.yml @@ -0,0 +1,31 @@ + +os: macos +locales: [en] +partials: + - intro + - setup/macos_slack + - setup/slack_settings + - setup/github + - ssh_key + - gcp_setup + - virtual_machine + - osx_vscode + - vscode_remote_ssh + - vscode_extensions + - cli_tools + - setup/oh_my_zsh + - setup/gh_cli + - ubuntu_gcloud + - gcp_setup_linux + - dotfiles_simple + - dotfiles_terminal + - zsh_default_terminal + - setup/ssh_agent + - ubuntu_docker + - kubernetes + - terraform + - ubuntu_spark + - ubuntu_python + - repo_overview + - dbeaver + - setup/kitt diff --git a/builds/macOS_keep_current.yml b/builds/macOS_keep_current.yml new file mode 100644 index 0000000..7665829 --- /dev/null +++ b/builds/macOS_keep_current.yml @@ -0,0 +1,6 @@ + +os: macos +locales: [en] +partials: + - keep_current + - python_checkup diff --git a/constants/constants.yml b/constants/constants.yml new file mode 100644 index 0000000..0dc6d8b --- /dev/null +++ b/constants/constants.yml @@ -0,0 +1,7 @@ + +PYTHON_VERSION: "3.8.12" +PYTHON_CHECKER_URL: "https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh" +PIP_CHECKER_URL: "https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh" +PIP_LOADER_URL: "https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py" +CODE_EDITOR: "VS Code" +CODE_EDITOR_CMD: "code" diff --git a/constants/repos.yml b/constants/repos.yml new file mode 100644 index 0000000..2fc6f3d --- /dev/null +++ b/constants/repos.yml @@ -0,0 +1,6 @@ + +branches: + setup: master + +aliases: + de_setup: data-engineering-setup diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..b0431d0 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,26 @@ + +# NOTE(ssaunier): This script needs https://github.com/lewagon/setup to be cloned as well + +## Build guides + +`bundle exec ruby build.rb` generates the setup guide markdown files at the repo root (e.g. `macOS.md`, `macOS.es.md`). + +Each file in `builds/` defines one guide: + +```yaml +os: macos +locales: [en, es] +partials: + - intro # local: _partials/intro.md / _partials/es/intro.md + - setup/github # remote: lewagon/setup _partials/github.md + - de_setup/direnv # remote alias: lewagon/data-engineering-setup _partials/direnv.md +``` + +Partials without a `/` are loaded from `_partials/` (English) or `_partials/{locale}/` (other locales). +Partials with a `/` are fetched from GitHub: `{repo}/_partials/{locale}/{name}.md`. Remote repo branches and aliases are configured in `constants/repos.yml`. + +Template variables available in all partials are defined in `constants/constants.yml`. + +CI runs the build on every push and commits the generated files if they changed. + +## Guide descriptions diff --git a/lib/build_spec.rb b/lib/build_spec.rb new file mode 100644 index 0000000..a86d164 --- /dev/null +++ b/lib/build_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require_relative 'localized_build' + +class BuildSpec + attr_reader :name, :os, :locales, :partials + + def initialize(name:, os:, locales:, partials:) + @name = name + @os = os + @locales = locales + @partials = partials + end + + def localized_builds(repos_cfg) + @locales.map { |locale| LocalizedBuild.new(self, locale, repos_cfg) } + end +end diff --git a/lib/builder.rb b/lib/builder.rb new file mode 100644 index 0000000..9a22437 --- /dev/null +++ b/lib/builder.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require_relative 'build_spec' +require_relative 'partial_cache' +require_relative 'generator' + +class Builder + def initialize(build_specs, constants, repos_cfg) + @build_specs = build_specs + @constants = constants + @repos_cfg = repos_cfg + end + + def run + builds = @build_specs.flat_map { |spec| spec.localized_builds(@repos_cfg) } + cache = PartialCache.new(builds) + Generator.new(builds, cache, @constants).run + end +end diff --git a/lib/generator.rb b/lib/generator.rb new file mode 100644 index 0000000..55cfdca --- /dev/null +++ b/lib/generator.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'liquid' + +class Generator + def initialize(localized_builds, cache, constants) + @localized_builds = localized_builds + @cache = cache + @constants = constants + end + + def run + @localized_builds.each do |build| + File.open(build.output_filename, 'w:utf-8') do |f| + build.partials.each { |partial| f << render(partial, build) } + end + warn "built #{build.output_filename}" + end + end + + private + + def render(partial, build) + variables = @constants.merge(partial.vars).merge('os' => build.os, 'build_md' => build.output_filename) + "#{Liquid::Template.parse(@cache[partial.url].clone).render(variables)}\n\n" + end +end diff --git a/lib/localized_build.rb b/lib/localized_build.rb new file mode 100644 index 0000000..7bb8f9d --- /dev/null +++ b/lib/localized_build.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require_relative 'partial' + +class LocalizedBuild + attr_reader :os, :locale, :partials + + def initialize(spec, locale, repos_cfg) + @name = spec.name + @os = spec.os + @locale = locale + @partials = spec.partials.map { |entry| Partial.from(entry, locale, repos_cfg) } + end + + def output_filename + @locale == 'en' ? "#{@name}.md" : "#{@name}.#{@locale}.md" + end +end diff --git a/lib/partial.rb b/lib/partial.rb new file mode 100644 index 0000000..a7f3951 --- /dev/null +++ b/lib/partial.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require_relative 'partial/remote' +require_relative 'partial/local' + +module Partial + REMOTE_REGEX = %r{\A(?[a-z][a-z0-9_-]*)/(?[a-z0-9_]+)\z} + + # entry is either a plain string or a hash: { 'name' => '...', 'vars' => { ... } } + def self.from(entry, locale, repos_cfg) + name = entry.is_a?(Hash) ? entry['name'] : entry + vars = entry.is_a?(Hash) ? entry.fetch('vars', {}) : {} + if (m = name.match(REMOTE_REGEX)) + Remote.new(m[:repo], locale, m[:name], vars, repos_cfg) + else + Local.new(locale, name, vars) + end + end +end diff --git a/lib/partial/local.rb b/lib/partial/local.rb new file mode 100644 index 0000000..92bb992 --- /dev/null +++ b/lib/partial/local.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Partial + class Local + attr_reader :url, :vars + + def initialize(locale, name, vars) + localized = "_partials/#{locale}/#{name}.md" + english = "_partials/#{name}.md" + @url = (locale != 'en' && File.exist?(localized)) ? localized : english + @vars = vars + end + + def content = File.read(@url, encoding: 'utf-8') + end +end diff --git a/lib/partial/remote.rb b/lib/partial/remote.rb new file mode 100644 index 0000000..33a86ba --- /dev/null +++ b/lib/partial/remote.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'open-uri' + +module Partial + class Remote + attr_reader :url, :vars + + def initialize(repo, locale, name, vars, repos_cfg) + repo = repos_cfg.dig('aliases', repo) || repo + branch = repos_cfg.dig('branches', repo) || 'main' + path = locale == 'en' ? name : "#{locale}/#{name}" + @base_url = "https://github.com/lewagon/#{repo}/blob/#{branch}" + @url = "https://raw.githubusercontent.com/lewagon/#{repo}/#{branch}/_partials/#{path}.md" + @vars = vars + end + + def content + text = URI.open(@url).read + # Rewrite relative image paths to absolute GitHub URLs so they render outside their source repo + text.scan(/\!\[.*\]\((.*)\)/).flatten + .reject { |ip| ip.start_with?('http') } + .each { |ip| text.gsub!(ip, "#{@base_url}/#{ip}") } + text.scan(/src="(images\/.*)"/).flatten + .each { |ip| text.gsub!(ip, "#{@base_url}/#{ip}") } + warn "fetched #{@url}" + text + end + end +end diff --git a/lib/partial_cache.rb b/lib/partial_cache.rb new file mode 100644 index 0000000..91ab0c1 --- /dev/null +++ b/lib/partial_cache.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class PartialCache + def initialize(localized_builds) + @cache = localized_builds + .flat_map(&:partials) + .uniq { |partial| partial.url } + .sort_by { |partial| partial.url } + .map { |partial| Thread.new { [partial.url, partial.content] } } + .map { |thread| thread.value } + .to_h + end + + def [](url) + @cache[url] + end +end diff --git a/macOS_keep_current.md b/macOS_keep_current.md index 2ed13b1..03d4596 100644 --- a/macOS_keep_current.md +++ b/macOS_keep_current.md @@ -86,10 +86,12 @@ type -a pyenv > /dev/null && eval "$(pyenv init --path)" Update pyenv : + ``` bash brew update && brew upgrade pyenv ``` + Install the current python version : ```bash @@ -140,6 +142,7 @@ pyenv versions pip install -U pip ``` + If your computer uses **Apple Silicon**, expand the paragraph below and go through it. Otherwise ignore it.
@@ -160,6 +163,7 @@ pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs ```
+ ## GCP Make sure that the `gcloud` command is linked to the email address of your Google Cloud Platform account : @@ -228,8 +232,7 @@ cat $GOOGLE_APPLICATION_CREDENTIALS { "type": "service_account", "project_id": "your-gcp-project-id", - "private_key_id": "a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4a2d4", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInMIInM=\n-----END PRIVATE KEY-----\n", + "private_key_id": "...", "client_email": "your-service-account@your-service-account.iam.gserviceaccount.com", "client_id": "105410541054105410541", "auth_uri": "https://accounts.google.com/o/oauth2/auth", @@ -268,8 +271,10 @@ gcloud auth configure-docker ## Docker + Start the Docker app + Verify that Docker can run the hello-world image : ``` bash @@ -278,24 +283,26 @@ docker run hello-world 👉 Make sure that this command completes correctly + Stop the Docker app + ### Python setup check up Check your Python version with the following commands: ```bash -zsh -c "$(curl -fsSL )" 3.8.12 +zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh)" 3.8.12 ``` Run the following command to check if you successfully installed the required packages: ```bash -zsh -c "$(curl -fsSL )" +zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh)" ``` Now run the following command to check if you can load these packages: ```bash -python -c "$(curl -fsSL )" +python -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py)" ``` Make sure you can run Jupyter: