新手入門 - Gitlab Continuous Integration & Deployment

前言

之前雖然有聽聞過CI(Continuous Integration)相關工具,但是一直沒有好好認真地研究,畢竟都是一個人寫,總認為自己也不太需要用到CI。直到最近開始上班了,看到了公司如何使用CI來進行build package流程,頓時覺得這工具實在很便利~而因為公司也早已經有完整架構,因此雖然看得到介面,卻還是不太清楚實際上到底是如何運作的,所以就趁雙十連假期間,決定自己來實際嘗試一下整個CI運作流程。

涉及內容

  1. Gitlab CI
  2. Docker

Gitlab底下的CI流程

Gitlab process

(Image reference: https://docs.gitlab.com/ee/ci/)

GitLab offers a continuous integration service. If you add a .gitlab-ci.yml file to the root directory of your repository, and configure your GitLab project to use a Runner, then each commit or push, triggers your CI pipeline.

Write a collection

前言
記得在6月份面試的時候,有考到自己寫Stack時,應該注意什麼地方,不過那時候很緊張,只有說到使用array來建構stack會有極限值或空值的問題,後來想想,其實還有element被pop之後的記憶體問題。剛好最近在看書複習時,書中只有簡單將top index - 1來限制可取得的element,導致即使array[index]的值被return後,array[index]實際上還是存在於記憶體中。

處理方式
Java
針對這個問題,去看了一下Java原始碼對於這部分的處理(arraydeque),果然它會先建立一個Result物件,然後將array[index] = null之後,返回Result,來避免上述所提到的問題。

C++
C++沒有garbage collection支援,所以處理上相對比較複雜一些。從vector的原始碼來看,裡面需要一個struct紀錄start, finish, end的值,再搭配allocate去配置記憶體,所以在執行stack pop時候,必須先.back()取得最後一個element的值,然後使用.pop_back()呼叫destory()來銷毀該element.

1
Alloc::destory(this->_M_impl, this->_M_impl._M_finish);

自己實作這些資料結構時候,可能有些小細節沒發現,所以參考原始碼能得到比較多啟示。而且即使是Java,涉及到collection依然會遇到記憶體處理問題(reference),所以還是要告誡自己在使用這些collections的時候要特別注意。

Jekyll

這是第一次用Jekyll寫紀錄,雖然我Project是使用Jekyll的概念來開發的,不過實際上我並沒有真的使用它過,主要原因是怕自己想法會因為這樣而被定型,所以當初在開發的時候,只有參考Jekyll網站上的流程圖而已。現在Project的Prototype已完成,就來使用一下,看有什麼可以改進的地方。就整體架構來說,其實差沒有很多,不過Jekyll在程式上分得更細,提供相當多的參數供開發者設定,以及很有彈性而且完整的template render,這些都是值得我後續學習。

This my first time to write articles with Jekyll. To be honest, I’d never use it before although my project was developed by using the concept of static site generators. The reason was my idea might be restricted due to the experiences of Jekyll. So I just read the process of Jekyll during project development. But now I thought it is time to try this system. I hope I could get some ideas that how can I improve my system.