Skip to content

Instantly share code, notes, and snippets.

View ArturT's full-sized avatar

Artur Trzop ArturT

View GitHub Profile
@ArturT
ArturT / Unix Philosophy - rules
Created March 22, 2020 15:01 — forked from olgaczarnecka/Unix Philosophy - rules
Some notes regarding Unix Philosophy (actually in my opinion they apply to general good programming practices) based on "The Art of Unix Programming by Eric Steven Raymond" (http://www.catb.org/esr/writings/taoup/html/graphics/taoup.pdf)
Basics of Unix philosophy:
- Use simple algorithms as well as simple data structures
- Data structures, not algorithms are central to programming - organise it well
- Fancy algorithms are buggier than simple ones
Rules:
Modularity - build out simple parts connected by well defined interfaces. Be able to update/upgrade the part without breaking the whole.
@ArturT
ArturT / postgres-upgrade-database-failed.log
Last active March 5, 2020 18:05
Postgres 11 to 12 upgrade database failed. Solution to fix it.
brew postgresql-upgrade-database
==> Upgrading postgresql data from 11 to 12...
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
Referenced from: /usr/local/Cellar/postgresql@11/11.7/bin/postgres
Reason: image not found
no data was returned by command ""/usr/local/Cellar/postgresql@11/11.7/bin/postgres" -V"
The program "postgres" is needed by pg_ctl but was not found in the
same directory as "/usr/local/Cellar/postgresql@11/11.7/bin/pg_ctl".
Check your installation.
==> Moving postgresql data from /usr/local/var/postgres to /usr/local/var/postgres.old..
@ArturT
ArturT / run_flaky_test_until_fails.sh
Last active February 23, 2023 17:07
How to reproduce a flaky test. Run a flaky test until it fails.
# bash
while [ "$?" == 0 ]; do rspec spec/flaky_spec.rb:123; done
# zsh
while rspec spec/flaky_spec.rb:123; do :; done
@ArturT
ArturT / cypress-codefresh.yml
Created October 19, 2019 15:18
Codefresh.io example for Cypress.io E2E test runner - parallel testing. Example from blog post https://docs.knapsackpro.com/2019/how-to-run-cypress-parallel-tests-on-codefresh-ci-server
# .codefresh/codefresh.yml
version: "1.0"
stages:
- "clone"
- "build"
- "tests"
steps:
main_clone:
@ArturT
ArturT / Test.Dockerfile
Created October 11, 2019 13:01
Codefresh.io matrix configuration for running parallel tests with Knapsack Pro for Ruby on Rails project (PostgreSQL + Docker setup). Follow installation guide for knapsack_pro ruby gem here https://docs.knapsackpro.com/knapsack_pro-ruby/guide/ or learn more about it at https://knapsackpro.com
# Test.Dockerfile
FROM ruby:2.6.5-alpine3.10
# Prepare Docker image for Nokogiri
RUN apk add --update \
build-base \
libxml2-dev \
libxslt-dev \
jq \
nodejs \
@ArturT
ArturT / main.yaml
Last active June 8, 2021 14:50
GitHub Actions CI config for Ruby on Rails project with MySQL, Redis, Elasticsearch - how to run parallel tests with Knapsack Pro https://knapsackpro.com/?utm_source=github&utm_medium=gist&utm_campaign=rails-mysql-redis-elasticsearch-on-github-actions&utm_content=sign_up See article https://docs.knapsackpro.com/2019/github-actions-ci-config-for-…
# .github/workflows/main.yaml
name: Main
on: [push]
jobs:
vm-job:
name: CI
runs-on: ubuntu-latest
@ArturT
ArturT / Cypress-GitHub-Actions-JavaScript.md
Last active October 4, 2019 16:01
Cypress parallel testing on GitHub Actions. How to use GitHub matrix to run parallel jobs to split Cypress.io tests with https://knapsackpro.com/?utm_source=github&utm_medium=gist&utm_campaign=cypress-on-github-actions&utm_content=sign_up

@knapsack-pro/cypress supports environment variables provided by GitHub Actions to run your tests. You have to define a few things in .github/workflows/main.yaml config file.

  • You need to set KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS environment variable in GitHub repository Settings -> Secrets. See creating and using secrets in GitHub Actions.
  • You should create as many parallel jobs as you need with matrix.ci_node_total and matrix.ci_node_index properties. If your test suite is slow you should use more parallel jobs.

Below you can find config for GitHub Actions.

Video demo Cypress and GitHub Actions

https://youtu.be/06Ghp1-coVo

@ArturT
ArturT / Jest-GitHub-Actions-JavaScript.md
Last active December 1, 2022 07:31
GitHub Actions config for NodeJS and Jest tests. Running parallel jobs for Jest test suite with https://knapsackpro.com/?utm_source=github&utm_medium=gist&utm_campaign=jest-on-github-actions&utm_content=sign_up

GitHub Actions config for running Jest tests with parallel jobs

@knapsack-pro/jest supports environment variables provided by GitHub Actions to run your tests. You have to define a few things in .github/workflows/main.yaml config file.

  • You need to set KNAPSACK_PRO_TEST_SUITE_TOKEN_JEST environment variable in GitHub repository Settings -> Secrets. See creating and using secrets in GitHub Actions.
  • You should create as many parallel jobs as you need with matrix.ci_node_total and matrix.ci_node_index properties. If your test suite is slow you should use more parallel jobs.

Below you can find config for GitHub Actions.

Video demo Jest and GitHub Actions

@ArturT
ArturT / main.yaml
Last active November 9, 2022 06:10
GitHub Actions - how to run parallel tests in RSpec for Ruby on Rails project. See article how to run RSpec on GitHub Actions for Ruby on Rails app using parallel jobs https://docs.knapsackpro.com/2019/how-to-run-rspec-on-github-actions-for-ruby-on-rails-app-using-parallel-jobs or sign up at https://knapsackpro.com/?utm_source=github&utm_medium=…
# .github/workflows/main.yaml
name: Main
on: [push]
jobs:
test:
runs-on: ubuntu-latest
# If you need DB like PostgreSQL, Redis then define service below.
@ArturT
ArturT / ci-server-config.yaml
Last active August 30, 2019 17:32
Knapsack Pro - how it works - CI server config
jobs:
- name: Run Ruby tests with Knapsack Pro
parallelism: 10 # run 10 parallel CI nodes
commands:
# Run RSpec specs in parallel
- run: bundle exec knapsack_pro:queue:rspec
# Run Minitest tests in parallel
- run: bundle exec knapsack_pro:queue:minitest