This week I worked on syslog integration in skynet and delve into details of skynet. I also started using Gitlab CI.

skynet

  • 弄了一套脚本来编译,安装 skynet,生成和管理 skynet 项目。大概用起来

    # 创建项目 helloworld
    sx new helloworld
    # 启动 skynet 应用
    cd helloworld
    sx skynet boot/helloworld.lua
    # 创建新的 skynet 应用
    sx new-app server
    sx skynet boot/server.lua
    # 执行 Lua
    sx lua
    

Gitlab CI

  • Gitlab documentation does not mention how to setup docker registry key. Indeed, it requires a pair of RSA keys, use private key in Gitlab and public key in docker registry.

  • In .gitlab-ci.yml, variables defined in job level is also effective in top fields, such as before_script and services. Here is an example to test Rails using MySQL and Postgres

    image: rails
    
    services:
        - redis
        - $DB
    
    cache:
        key: bundle
        paths:
            - vendor/bundle
    
    variables:
        POSTGRES_DB: center_test
        POSTGRES_USER: runner
        POSTGRES_PASSWORD: ""
        MYSQL_DATABASE: center_test
        MYSQL_ROOT_PASSWORD: root
    
    before_script:
        - cp config/database.ci-$DB.yml config/database.yml
        - cp .ci.env .env
        - bundle install --jobs $(nproc) --path=vendor/bundle
    
    .test: &test_template
        script:
            - bundle exec rake db:create RAILS_ENV=test
            - RAILS_ENV=test bundle exec rake db:reset
            - bundle exec rake test
    
    test_pg:
        <<: *test_template
        variables:
            DB: postgres
    
    test_mysql:
        <<: *test_template
        variables:
            DB: mysql
    
  • Using Docker Build - GitLab Documentation. I use dind to build docker images in Gitlab CI. It requires starting docker in privilege mode, which breaks some containers such as mysql. A simple solution is registering 2 docker runners, one is in privilege and another is not. Tag runners and add tags in .gitlab-ci.yml to filter runner.

  • In Mac, gitlab-ci-multi-runner must be started in user desktop environment. The runner may stuck at checkout code because the GUI is asking for keychain access. Just approve the access in desktop environment.

DevOps

Misc