How to fix frequency drift when producing an arbitrary length signal by repeatedly looping over a single-period waveform?
My suggestion is to use a Numerically Controlled Oscillator (NCO). A typical NCO effectively has one cycle of a sine wave in memory and can play back that sine wave as a continuous waveform with very high frequency resolution. But this needn't be a sine wave: you could have any waveform in memory and adjust the rate at which it plays back in the same fashion. That said, I believe these posts will be helpful where I provide more details on how an NCO works:

Numerically Controlled Oscillator (NCO) for phasor implementation?

Problem in understanding DDFS (Direct Digital Frequency Synthesizer.)

As a simplest explanation the approach is to count through the the waveform at a fixed rate (the sampling rate) with an increment that is proportional to the output frequency desired. The higher the precision of your counter (accumulator), the higher precision in frequency can be achieved. If you count with an increment if 1, you will get the lowest non-zero frequency out, and it will take $2^n$ counts to get through the entire waveform in memory once where n is the precision of the accumulator. Only the MSB’s of the accumulator are needed to address the memory based on how big the memory is. If you count by 2 that frequency will twice as fast, etc. So ultimately the frequency resolution is 

$$f_\Delta=\frac{f_{clk}}{2^n}$$

Where $f_{clk}$ is the sample rate and n is the number of bits in the accumulator. 

And the output frequency assuming the memory contains exactly one cycle of your waveform will be

$$f_{out}= Nf_\Delta$$

Where N is the count increment.

So for example with a 10 MHz clock (update rate) and a 32 bit accumulator which are both typical and practical values, you can generate output frequencies in the 0 to 5MHz first Nyquist zone with 2.33 mHz resolution!  (If combining with an D/A converter the practical upper limit would be approximately 40 MHz to allow for image filtering and an inverse Sinc filter would be considered to compensate for the Sinc reconstruction droop). 

The links above go into full details of design parameters including signal quality (SNR and spur levels) and considerations on how many address bits should go to memory etc.